Groovy/Grails Contains with Lowercase
up vote
6
down vote
favorite
I want to check a list contains a specific string .
before checking all entries in list as well as sting should be in. lowercase
I tried like this
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
}
gives error
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:
java list grails groovy
add a comment |
up vote
6
down vote
favorite
I want to check a list contains a specific string .
before checking all entries in list as well as sting should be in. lowercase
I tried like this
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
}
gives error
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:
java list grails groovy
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I want to check a list contains a specific string .
before checking all entries in list as well as sting should be in. lowercase
I tried like this
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
}
gives error
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:
java list grails groovy
I want to check a list contains a specific string .
before checking all entries in list as well as sting should be in. lowercase
I tried like this
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
}
gives error
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:
java list grails groovy
java list grails groovy
edited Jan 9 '13 at 8:17
asked Jan 9 '13 at 8:11
maaz
1,349153980
1,349153980
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
15
down vote
accepted
I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
add a comment |
up vote
6
down vote
If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.
If you need to check it manually, try this:
def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
if(venueWithNameFromParams){
// venueName is in venueNameList
}
add a comment |
up vote
0
down vote
If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.
For example, the following will be positive condition:
word = "YES"
word.matches(/(?i)yes|ok|true/)
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
15
down vote
accepted
I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
add a comment |
up vote
15
down vote
accepted
I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
add a comment |
up vote
15
down vote
accepted
up vote
15
down vote
accepted
I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:
venueNameLists*.toLowerCase().contains(venueName.toLowerCase())
answered Jan 9 '13 at 9:01
Mr. Cat
2,91821224
2,91821224
add a comment |
add a comment |
up vote
6
down vote
If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.
If you need to check it manually, try this:
def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
if(venueWithNameFromParams){
// venueName is in venueNameList
}
add a comment |
up vote
6
down vote
If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.
If you need to check it manually, try this:
def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
if(venueWithNameFromParams){
// venueName is in venueNameList
}
add a comment |
up vote
6
down vote
up vote
6
down vote
If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.
If you need to check it manually, try this:
def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
if(venueWithNameFromParams){
// venueName is in venueNameList
}
If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.
If you need to check it manually, try this:
def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
if(venueWithNameFromParams){
// venueName is in venueNameList
}
edited May 23 '17 at 12:32
Community♦
11
11
answered Jan 9 '13 at 8:41
aiolos
3,6301525
3,6301525
add a comment |
add a comment |
up vote
0
down vote
If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.
For example, the following will be positive condition:
word = "YES"
word.matches(/(?i)yes|ok|true/)
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
add a comment |
up vote
0
down vote
If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.
For example, the following will be positive condition:
word = "YES"
word.matches(/(?i)yes|ok|true/)
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
add a comment |
up vote
0
down vote
up vote
0
down vote
If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.
For example, the following will be positive condition:
word = "YES"
word.matches(/(?i)yes|ok|true/)
If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.
For example, the following will be positive condition:
word = "YES"
word.matches(/(?i)yes|ok|true/)
answered Nov 19 at 11:56
Noam Manos
5,56713040
5,56713040
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
add a comment |
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
1
1
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
See how it works in this snippet: tpcg.io/tSzWFd
– Noam Manos
Nov 21 at 10:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14230789%2fgroovy-grails-contains-with-lowercase%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown