Question

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 ... 
Was it helpful?

Solution

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|..."

OTHER TIPS

In VisualBasic.NET, you can use the RegExOptions to ignore he case:

Dim RegexObj As New Regex("([^.]+[.](jpg|jpeg|gif))", RegexOptions.IgnoreCase)

According to the Regular Expression Options, this should work:

// Added LowerCase i:
ValidationExpression="(?i:[^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top