RegExp.escape()

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Jun 29 18:37:46 UTC 2015


On Jun 27, 2015, at 9:17 AM, Mark S. Miller wrote:

> Safety over readability please. If there is a single fully escaped form that is safe to use in all the expected contexts, let's choose that. The results of RegExp.escape are not very readable anyway, and rarely read. So compromising safety for some contexts in exchange for incremental readability improvements of something that won't be read is not a good idea.
> 
> If there is not a clearly most escaped form that is safe in all expected contexts, then first, let us enumerate all the relevant contexts and the escaping demands of each.

Alternatively, an optional options object argument could be used to adapt a single 'escape' function to differing use case requirements.

Allen



More information about the es-discuss mailing list