Created
October 29, 2016 04:48
-
-
Save gkucmierz/50a39f9b52c4d2a3fa7902d3d7330aec to your computer and use it in GitHub Desktop.
Escape string for RegExp
This file contains hidden or 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 escapeRegExp(str) { | |
| return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment