Make regular expression case insensitive in ASP.NET RegularExpressionValidator

I found out.

Case sensitive: ^[0-9]\s(lbs|kg|kgs)$

Case insensitive: (?i:^[0-9]\s(lbs|kg|kgs)$)

I believe that this is specific to the .NET implementation of regular expressions. So if you use this in the RegularExpressionValidator you have to turn off client side validation because the javascript regex parser will not recognize the ?i token.

Leave a Comment