Yea, I know thats why I said <i>"Trouble is, that this also matches 321, 213 AND 123."</i> It also won't allow 1, 2 or 3 either, as Jon points out.
I searched high and low, and theirs singular regex i can find that will do a group () not matching.
(^123) doesn't work
^(123) matches 123 at the beginning of a line
[^(123)] doesnt work, grouping operations are not allowed in side []
[^1][^2][^3] only matches strings of three digits so abcd is not validated but abc is.
etc etc
However, I then tried doing some logical regular expressions as well and came up with this:
Code:
(?(?=\b123\b)[^123]+|[0-9a-zA-Z\s]+)
using the regex coach (
The expression basically states:
" if the expression matches 123, then dont match 1, 2 or 3 or match everything."
but, interestingly enough, although this is a valid expression in the coach, the Xerces parser doesn't like it
and throws this error: "This expression is not supported in the current option setting." There must be some settings that need adjusting somewhere.
HOWEVER! the .NET validator I posted before has NO PROBLEM WHATSOEVER with this regular expression and validates correctly.
So, give it a try and see.
Matt