Skip to content

Instantly share code, notes, and snippets.

@jahewson
Created January 24, 2012 11:18
Show Gist options
  • Save jahewson/1669691 to your computer and use it in GitHub Desktop.
Save jahewson/1669691 to your computer and use it in GitHub Desktop.
RegEx escape
function escapeRegEx(str) {
return str.replace(/([\^\$\(\)\<\>\|\\\{\[\]\.\*\+\?])/g, '\\$1');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment