Created
June 14, 2012 14:50
-
-
Save suisho/2930802 to your computer and use it in GitHub Desktop.
convert wild card string to
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
function wildCardToRegexp(wildCardPattern){ | |
var regexpOperator = '^$\\.+?()[]{}|'; | |
for(var i = 0; i < regexpOperator.length; i++){ | |
var operator = regexpOperator[i]; | |
wildCardPattern = wildCardPattern.replace(operator,"\\"+operator); | |
} | |
return wildCardPattern.replace("*",".*"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment