Reputation: 23935
I have an ASP.NET RegularExpressionValidator that checks file extensions. Is there a quick way I can tell it to ignore the case of the extension without having to explicitly add the upper case variants to my validation expression?
ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...
Upvotes: 13
Views: 32502
Reputation: 1062780
Server-side, "(?i)" can be used, but this doesn't work client-side. See here for more discussion and workaround.
i.e. "...(?i)(jpg|jpeg|gif|png|wpf|..."
Upvotes: 24
Reputation: 180944
According to the Regular Expression Options, this should work:
// Added LowerCase i:
ValidationExpression="(?i:[^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...
Upvotes: 1
Reputation: 5706
In VisualBasic.NET, you can use the RegExOptions to ignore he case:
Dim RegexObj As New Regex("([^.]+[.](jpg|jpeg|gif))", RegexOptions.IgnoreCase)
Upvotes: 2