Any way to get a regex working in a report format using string.contains?

Answered on Discord, but I’ll copy it (slightly edited for clarity) here for posterity:

You can use string.matches() instead; it takes a regex expression. So, something like: result.matches(".*(1|2).*").

That should match any string that starts with any number of any characters (including none) followed by a “1” or “2” followed by any number of any characters.

FYI, if you need to match a multi-character string, it would be result.matches(".*(string1)|(string2).*"); note that each side of the bar needs to be in parentheses in that case.

1 Like