Reputation: 1
I need help with regular expression. What is allowed is all the:
What is not allowed:
I've tried different ways and not getting anywhere. in my model i have the following
[RegularExpression(@"^(?:(?!\b(?i:AND|O[RK]|NOT|FALSE|TRUE)\b)[\wåäöÅÄÖ\._])*$", ErrorMessageResourceName =
but im getting a javascript exception ? problem with the case sensitive i
Unhandled exception at line 660, column 6 in eval code
0x800a139a - JavaScript runtime error: Unexpected quantifier
What am I doing wrong?
Upvotes: 0
Views: 1940
Reputation: 4659
You put the word-boundary \b
and the negative lookahead inside the character class. This is what I would do and set ignore case:
^(?:[B-MP-ZåäöÅÄÖ\._]|\bA(?!ND\b)|\bN(?!OT\b)|\bO(?![KR]\b))*$
Upvotes: 0
Reputation: 71578
1 & 2
Swedih alphabet (includes alphabet from the english language, and those you mentioned in your regex), numbers and underscore: [\wåäöÅÄÖ]
3
Add dot...: [\wåäöÅÄÖ.]
4
No strange characters in the above character class
5
No white space allowed in the above character class
6
Specific words through a negative lookahead and adding anchors and quantifiers and flag:
@"^(?:(?!\b(?:AND|O[RK]|NOT)\b)[\wåäöÅÄÖ.])*$", RegexOptions.IgnoreCase
Upvotes: 2