Does it still read the string?

On Fri, Nov 6, 2015, 20:59 Gorkem Yakin <goya...@microsoft.com> wrote:

> I don’t know about other engines, but Chakra does cache the RegExp matcher
> when the RegExp object is created via the constructor.
>
>
>
> Gorkem
>
>
>
> *From:* es-discuss [mailto:es-discuss-boun...@mozilla.org] *On Behalf Of 
> *Isiah
> Meadows
> *Sent:* Friday, November 6, 2015 4:36 PM
> *To:* C. Scott Ananian <ecmascr...@cscott.net>; Brian Terlson <
> brian.terl...@microsoft.com>
> *Cc:* es-discuss@mozilla.org
> *Subject:* Re: RegExp free-spacing & comments
>
>
>
> The problem with using the RegExp constructor is that it is never cached
> by the engine. As a literal, engines usually internalize them, speeding up
> matches very quickly.
>
>
>
> On Fri, Nov 6, 2015, 14:24 C. Scott Ananian <ecmascr...@cscott.net> wrote:
>
> On Fri, Nov 6, 2015 at 1:20 PM, Brian Terlson
> <brian.terl...@microsoft.com> wrote:
> > RegExp.re or similar seems nice:
> >
> > ```
> > let re = RegExp.re("x")`
> >     (\d{3}-)? # area code (optional)
> >     \d{3}-    # prefix
> >     \d{4}     # line number
> > `;
> > ```
> >
> > But it seems like previous proposals of this want escaping which doesn't
> seem ideal for this purpose. Do we need both `RegExp.re` and
> `RegExp.escapedRe`?
>
> Escaping happens if you use interpolation into the string template:
> ```
> let re = RegExp.re`(?x:
>     (\d{3}-)?      # area code (optional)
>     ${ /\d{3}/ }-  # prefix
>     \d{4}           # line number
>     ( ${ "*" } \d+ )?  # extension
> )`;
> ```
> If the interpolated expression is a regexp, then things seem
> relatively straightforward (although there are corner cases to
> consider).  If the interpolated expression is a string, then it is
> suggested that you use some sort of automatic escaping.
>  --scott
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> <https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.mozilla.org%2flistinfo%2fes-discuss&data=01%7c01%7cgoyakin%40microsoft.com%7c0ebaa0e85f994ffe3c0708d2e70b81db%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=g9mQNk%2bq0%2bD8%2bwq6NdZf95q9eWMoaq2OhvMhT3kwiRs%3d>
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to