The *
is a meta character which means 'zero or more times' the thing you matched before, but in this case there is nothing to match. This should probably work:
String myRegex = ".*cow"
String name = "SHIRACOWPEPPER"
name = name.toLowerCase()
if(!name || name.matches(myRegex)) {
return true
}
For more information see the documentation