Is there any way to use the “in” operator for a list with a regexp inside?
List myList = ["abc", "xyz", ~/a.+z/]
assert ("abc" in myList) == true
assert ("xyz" in myList) == true
assert ("abz" in myList) == true
assert ("aby" in myList) == false
Thanks for any help.
I don’t think there’s a way to get this to work with
in. The best I can think of is to write a custom method, and running that instead like so:Actually, this is possible, but you’ll need to either write your own
Listclass:Or, overwrite the
isCasemethod on the instance meta class for your list: