Search code examples
asp.netregexignore-case

How can I ignore case in a regex?


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

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