I found this post which describes how to compare two arrays against one another very well. However, if I have some input string given from user like "20394875apple29038475" or "i love apples" and I want to check if any of the strings in a string array are present in the user given string regardless of upper/lower case, how can i do this in groovy?
Let's imagine the string array we are checking to have fruits like ("apple","banana","cherry").
In this case we would return true because the substring "apple" is present in the user given string "20394875apple29038475"
... I am thinking that the best way would be something like this?:
boolean fruitFound = false
for (item in fruitArray){
if(usrResponse.contains(item)){
responseFound = true
}
fruitFound = fruitArray.any{usrResponse.contains(it)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With