Does the RegExp /y modifier require /g?
Brendan Eich
brendan at mozilla.org
Mon Dec 24 13:15:00 PST 2007
On Dec 24, 2007, at 8:44 AM, StevenLevithan wrote:
> (I emailed this to the list last night, but it doesn't seem to have
> gone
> through. Sorry if this becomes a dupe.)
(I don't see a moderator request based on your sending from a
different e-mail address -- I don't see a dup either.)
> Given the above rule, my questions are:
>
> 1. Does ES4's /y (sticky) modifier have any meaning if the /g (global)
> modifier is not also set?
Yes.
> 2. What about with String.prototype.split and
> String.prototype.search, which
> ignore the values of regexp.global and regexp.lastIndex?
The /y flag makes unanchored regexps match or fail at the current
position in the target string, period. Where the current position is
may depend on /g and other things, but /y is independent (lower-
level) than these considerations.
> I'm working on code which brings some of the ES4 regex features
> (including
> /y) to current browsers, but I'm not sure which way to go on these
> points.
Firefox 3 is in beta release now and has supported /y since an early
alpha. See https://bugzilla.mozilla.org/show_bug.cgi?id=371932.
/be
More information about the Es4-discuss
mailing list