RegExp.escape()

Benjamin Gruenbaum benjamingr at gmail.com
Mon Jun 29 18:45:16 UTC 2015


I meant something like `RegExp.escape(str, "☺")` (also escapes `☺`). Since
strings are iterable by code points via the new iteration protocol this
sounds like the natural choice. I'm not sure such a second argument would
be a good idea.

On Mon, Jun 29, 2015 at 9:42 PM, C. Scott Ananian <ecmascript at cscott.net>
wrote:

> Please, not an iterable over characters.  (Or at least, "not only".) Use a
> RegExp.  Imagine trying to ensure that any characters over \u007f were
> escaped.  You don't want an iterable over ~64k characters.
>
> In addition, a RegExp would allow you to concisely specify "hex digits,
> but only at the start of the string" and some of the other oddities we've
> considered.
>   --scott
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150629/200bb16a/attachment-0001.html>


More information about the es-discuss mailing list