RegExp.escape

C. Scott Ananian ecmascript at cscott.net
Fri Jun 12 20:16:25 UTC 2015


@Alexander Jones: no new syntax is needed to implement what you want; we
already have Template Strings.  For example, you could define a new
function `RegExp.join` (which takes either an array or a string as its
first argument, see below):

```
var pattern = RegExp.join`^(abc${ "someString, escaped" }|def${ /a reg|exp/
})$`
// apply flags?
var pattern = RegExp.join('x')` abc | def \$`;
```

`RegExp.escape()` would be used internally to handle the interpolation of
an string into the regexp.  But these features are orthogonal.
 --scott


On Fri, Jun 12, 2015 at 2:57 PM, Juriy Zaytsev <kangax at gmail.com> wrote:

> I made this gist back in the days — https://gist.github.com/kangax/9698100
> — and I believe Rick was going to bring it up at one of the meetings. I
> don't have time to set up repo and work with TC39 member so if you can
> continue carrying that torch, that would be awesome!
>
> --
> kangax
>
> On Fri, Jun 12, 2015 at 2:52 PM, Benjamin Gruenaum <benjamingr at gmail.com>
> wrote:
>
>> You know what? Why not. I'm going to try to champion this.
>>
>> I talked to Domenic and he said he's willing to help me with this which
>> is a big help (this would be my first time).
>>
>> I'll open a GitHub repo and see what I can come up with.
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150612/49917d60/attachment.html>


More information about the es-discuss mailing list