regexp.escape
A robust & optimized ES3-compatible polyfill for the RegExp.escape
proposal for ECMAScript 7.
Use it to safely escape RegExp special tokens for use in new RegExp
.
Use it as a standalone function, or call its shim
method to install it as a polyfill.
Example
var escape = ;var assert = ; var str = 'hello. how are you?';var regex = 'g';assert;
Tests
Simply clone the repo, npm install
, and run npm test