Skip to content

Instantly share code, notes, and snippets.

@suisho
Created June 14, 2012 14:50
Show Gist options
  • Save suisho/2930802 to your computer and use it in GitHub Desktop.
Save suisho/2930802 to your computer and use it in GitHub Desktop.
convert wild card string to
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