C. Scott Ananian ecmascript at
Fri Mar 21 08:38:13 PDT 2014

One more for the "it's too late for ES6" train: most other programming
languages have a convenient "safe" way to turn a string into a regular
expression matching that string.  `RegExp.escape` is often suggested
as the function name.  I think this is worth adding to the standard
library because it helps patch a ["candy machine
interface"]( -- that is, I've seen the
following too often (including again today, hence this message):

function replaceTitle(title, str) {
  return str.replace(new RegExp(title), "...");

There ought to be a standard simple way of writing this correctly.

Has this been discussed in the context of ES6/ES7 before?

More information about the es-discuss mailing list