Regular Expressions and Alternation


(Lewis) #1

I’m trying to use regular expressions in Complex Validation Rules for a Squiz custom form to highlight reference numbers.

I’ve written a regular expression which works fine for my purposes on regex101.com but when I put it into the custom form, it doesn’t present an error message.

I’ve seen elsewhere in the forum that there’s a possibility Squiz doesn’t interpret alternations (’|’) in regular expressions. Is this true and if so, what should I use instead?

Here’s my expression: (?<=a/c|acc|account|ref|reference)\b\D+[0-9A-Za-z-\/]+ as I’m using it in the custom form (no delimiters, as it says).

Any ideas??


(Lewis) #3

It seems like Squiz doesn’t like escape characters ‘\’ in regular expressions in this context. Removing them made the regex work fine.