Skip to content

Instantly share code, notes, and snippets.

@k-maru
Created January 9, 2014 12:14
Show Gist options
  • Save k-maru/8333198 to your computer and use it in GitHub Desktop.
Save k-maru/8333198 to your computer and use it in GitHub Desktop.
Escape RegExp String
escapeRegExp = function (value){
if(Object.prototype.toString.call(value) !== "[object String]") value = value + "";
return value.replace(/([\\/'*+?|()\[\]{}.^$])/g,'\\$1');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment