RegExp.escape(str)

Simply put, it would be nice if the function to escape string literals for use within a regular expression were a polyfillable standard (as described at http://stackoverflow.com/a/3561711/34799).

3 Likes

I have put together a prollyfill for this: https://github.com/jonathantneal/regexp-escape

1 Like

Apparently this was proposed in es-discuss 5 years ago with some new discussion taking place now: https://esdiscuss.org/topic/regexp-escape

Ugh.