RegExp lastIndex
syntax: |
regexp.lastIndex |
description: |
The character position after the last pattern match and which is the basis for subsequent matches when finding multiple matches in a string. That is, in the next search, lastIndex is the starting position. This property is used only in global mode after being set by using the "g" attribute when defining or compiling a search pattern. RegExp exec() and RegExp test() use and set the lastIndex property. If a match is not found by one of them, then lastIndex is set to 0. Since the property is read/write, you may set the property at any time to any position.
Read/write property.
|
see: |
|
example: |
var str = "one tao three tio one"; var pat = /t.o/g; pat.exec(str); // pat.lastIndex == 7 |