headerphoto

Property: lastIndex

Syntax

var exp = new ApgExp(pattern);
var n; /* integer > 0 */
exp.lastIndex = n;

Regardless of the matching mode, the pattern match attempt is made starting at index, exp.lastIndex. The user can set exp.lastIndex to any value prior to the match attempt. The value of exp.lastIndex after the match attempt is mode and result dependent.

Example

var pattern, str, exp, result;    
pattern = 'pattern = "abc"\n';
exp = new ApgExp(pattern);
exp.lastIndex = 6;
str = "---abc---ABC---";
result = exp.exec(str);
if(result){
  console.log("found: " + result[0] + " :at: " + result.index);
}else{
  console.log("result: null");
}
/* returns */
found: ABC :at: 9