Standard built-ins

RegExp.lastIndex

Try the free JavaScript compiler

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.lastIndex

Return 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);
JavaScript Reference