[Solved] How to Regular Expression match not having a constant at the end of a string (.net validator)


(?> … ) is the syntax for an atomic grouping. And the syntax for look-ahead assertion is just (?! … ).


Edit   Try this regular expression instead:

.*$(?<!-CONST)

The .*$ will consume everything and the look-behind assertion will exclude those that end with a -CONST.


Edit    Just for completeness’ sake: If your regular expression language does not allow look-behinds, you can also use this one using a look-ahead assertion:

^(.{0,5}|.*(?!-CONST).{5})$

Or using just alternations:

^(.{0,5}|.*([^-].{5}|-([^C].{4}|C([^O].{3}|O([^N].{2}|N([^S].|S[^T]))))))$

5

solved How to Regular Expression match not having a constant at the end of a string (.net validator)