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 ...
Regular expression pattern matching may be case sensitive. To make a word or phrase case insensitive, use the regular expression /i . For example, /bad language/i will block all instances of "bad language", regardless of case.
re. IGNORECASE : This flag allows for case-insensitive matching of the Regular Expression with the given string i.e. expressions like [A-Z] will match lowercase letters, too. Generally, It's passed as an optional argument to re. compile() .
Case Insensitive Search By default, grep is case sensitive. This means that the uppercase and lowercase characters are treated as distinct. To ignore case when searching, invoke grep with the -i option (or --ignore-case ).
Case-Sensitive MatchBy default, regexpi performs case-insensitive matching. Use the regexp function with the same syntax as regexpi to perform case-sensitive matching. To disable case-sensitive matching for regexp , use the 'ignorecase' option.
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|..."
In VisualBasic.NET, you can use the RegExOptions to ignore he case:
Dim RegexObj As New Regex("([^.]+[.](jpg|jpeg|gif))", RegexOptions.IgnoreCase)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With