Does the RegExp /y modifier require /g?

Steve steves_list at hotmail.com
Mon Dec 24 14:53:45 PST 2007


>> 1. Does ES4's /y (sticky) modifier have any meaning if the /g (global)
>> modifier is not also set?
>
> Yes.

My question was very poorly worded. I was thinking along the lines of 
behavior being affected by lastIndex (set manually or via the use of /g).

> 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. [...]
> 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.

Thanks. Your response and the Firefox 3 beta answers all my questions on 
this point. The /y modifier is a great addition and every aspect of it seems 
to work like I would expect/hope.
 




More information about the Es4-discuss mailing list