[英]Creating grails binary plugin results in jar file which contains all groovy files with comments
[英]Groovy/Grails Contains with Lowercase
我想檢查包含特定字符串的列表。
在檢查列表中的所有條目之前以及sting應該是。小寫
我試過這樣的
def venueName = params.name
def venueNameLists = Venue.executeQuery("select name from Venue")
if(venueNameLists.toLowerCase().contains(venueName.toLowerCase())){
error = true;
log.debug("save :: duplicate name")
flash.message = "Venue name already exist";
render(view: "create", model: [venueInstance: new Venue(params)])
return
}
給出錯誤
No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: []. Stacktrace follows:
groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: []
我同意aiolos :使用約束或嘗試按名稱忽略大小寫查找實例。 但要按照你的方式解決這個問題*.
( 傳播運營商 ):
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
如果您正在查看如何檢查多個字符串是否包含單詞,而忽略區分大小寫,請在單詞的正則表達式上使用(?i)。
例如,以下將是積極的條件:
word = "YES"
word.matches(/(?i)yes|ok|true/)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.