Using the "Regular Expression Validator" in a TV

I had an issue with the validator and came across this post on the old forums:

It wasn’t really resolved but I did need to figure it out.

I’m on 2.8.1-pl

Turns out I do NOT need to surround the regex with any delimiter. So don’t add /…/ or %…% to the pattern.
And I DID need to double-backslash any time it was used.

My pattern was for a text box and only allowing a ##,##,## type pattern. It has to start with a number, and not end in a comma, and not allow multiple commas in a row. The pattern was exactly this:

^\\d+(\\,{1}\\d+)*$

If I add % or / around it, it fails. If I have single backslash, it fails.

Just in case anybody searches for this type of issue.

1 Like