String.contains
contains($matchString, $options={}) -> boolean
Description
Check for the existence of $matchString
and return true
or false
.
If $options
is -ignoreCase
it will match both upper and lowercase versions of each character.
'abcdef'.contains('def') //= true 'abcdef'.contains('xyz') //= false 'abcdef'.contains('CDE', -ignoreCase) //= true
Regex Patterns
The $matchString
argument can also be a Regex.
// \d+ = one or more digits 'abc 123 xyz'.contains(rx'\d+') //= true // i = ignore case '123 Abc Xyz'.contains(rx'(abc|def)'i) //= true