Last active
January 28, 2024 21:32
-
-
Save UweKeim/40f8b02de15f42fa256ce1edb46fbf33 to your computer and use it in GitHub Desktop.
Convert wildcards to Regular Expressions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string convertWildcardToRegex(string pattern) | |
{ | |
// http://stackoverflow.com/a/6907849/107625 | |
// http://www.codeproject.com/Articles/11556/Converting-Wildcards-to-Regexes | |
return "^" + Regex.Escape(pattern). | |
Replace("\\*", ".*"). | |
Replace("\\?", ".") + "$"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment