archives

« Bugzilla Issues Index

#526 — Add RegExp.prototype.sticky (flag /y)


http://wiki.ecmascript.org/doku.php?id=harmony:regexp_y_flag is an accepted proposal, and should be added to the ES6 draft spec.

That said, the brief description on the wiki leaves out a few key details.

1. The current text makes it sound like /y should always cause lastIndex to be updated upon a successful match. However, the public lastIndex property should only be updated (to 0 upon failure, and to match.index+match[0].length on success) if flag /g is also present, the same as always.

2. No mention is made of how an explicit ^ anchor within the RegExp should be handled. This has caused some confusion: see https://bugzilla.mozilla.org/show_bug.cgi?id=773687 . Specifically, an explicit ^ should always match only at the beginning of the entire target string, or at the beginning of a line if used with /m.

As for the revision 9 draft, it includes a passing mention of flag /y (and /u) in §11.1.8, but does not specify the flag itself. It should be added at least to §15.10.4.1, §15.10.6.4, and as a new subsection of §15.10.7.


Also, although this is probably obvious, flag /y should impact all methods that use a RegExp to search: regex.exec/test and str.search/split/replace/match.


recategorized to make sure these issues are covered


fixed in rev20 editor's draft


fixed in rev20 draft, Oct. 28, 2013