« Bugzilla Issues Index

#526 — Add RegExp.prototype.sticky (flag /y) 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 . 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 §, §, 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

recategorized to make sure these issues are covered

fixed in rev20 editor's draft

fixed in rev20 draft, Oct. 28, 2013