Should RegExp(regexp, flags) always return a functional RegExp for reasonable values of flags?
ljharb at gmail.com
Thu May 19 15:54:08 UTC 2016
I'm not as sure about `eval`, but absolutely `new RegExp(rx.source,
rx.flags)` should always imo reproduce a functionally equivalent regex.
On Thu, May 19, 2016 at 8:21 AM, Claude Pache <claude.pache at gmail.com>
> Given a RegExp object `rx` and a string `f` that contains legal RegExp
> flag characters, should ideally the following expressions
> RegExp(rx, f)
> eval("/" + rx.source + "/" + f)
> always return a functional regexp?
> Practical example: `rx = /\-/`, and `f === "u"` (recall that `\-` is
> invalid in u-regexps but valid in non-u-regexps).
> One may wish that `RegExp(/\-/, "u")` and `eval("/" + /\-/.source + "/u")`
> be both equivalent to `/-/u`.
> Context: That question came up while I was thinking about a possible
> precise specification for `RegExp.prototype.source`.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss