(I emailed this to the list last night, but it doesn't seem to have gone
through. Sorry if this becomes a dupe.)
-----

As far as I understand from ECMA-262 3rd Edition, the regexp.lastIndex
property is meaningless if a regexp does not use the /g modifier. Quoting
from E262v3 ยง15.10.6.2 (RegExp.prototype.exec):

> 4. Let i be the value of ToInteger(lastIndex).
> 5. If the global property is false, let i = 0.

So, e.g., the following returns true, although it would return false if /g
were used:

var re = /x/;
re.lastIndex = 2;
re.test("xyz"); // true

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?

2. What about with String.prototype.split and String.prototype.search, which
ignore the values of regexp.global and regexp.lastIndex?

The extend_regexps proposal on the wiki does not specifically mention these
points, and the sticky modifier does not appear to be implemented in the ES4
reference implementation (the sticky property gets set with /y, but it
doesn't appear to work).

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.

-- 
View this message in context: 
http://www.nabble.com/Does-the-RegExp--y-modifier-require--g--tp14488851p14488851.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at 
Nabble.com.

_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to