View Subcategory

Check if a string matches a regular expression

Display "ok" if "Hello" matches /[A-Z][a-z]+/
fantom
if (Regex<|[A-Z][a-z]+|>.matches("Hello"))
echo("ok")

Check if a string matches with groups

Display "two" if "one two three" matches /one (.*) three/
fantom
m := Regex<|one (.*) three|>.matcher("one two three")
if (m.matches)
echo("${m.group(1)}")