Standard built-ins
RegExp.lastIndex
Writable property used by built-in global and sticky matching. Successful matches set it to the end offset; failed matches reset it to zero.
Formal Syntax & Structure
javascript syntaxjavascript
regex.lastIndexReturn Value
Number
Stored index value (ordinary initialized value is zero).
Working Example
Example Snippetjavascript
const r=/a/g; r.test("ba"); console.log(r.lastIndex);