lastIndex property is set to a different value : lastIndex « Regular Expressions « Flash / Flex / ActionScript






lastIndex property is set to a different value

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var reCase:RegExp = new RegExp("abc", "ig");
        var sVal:String = "aBcdefabCdefABC";
        var aMatch:Array = reCase.exec(sVal);
        trace(aMatch + " - " + reCase.lastIndex); 
        reCase.lastIndex = 0;
        aMatch = reCase.exec(sVal);
        trace(aMatch + " - " + reCase.lastIndex);
        reCase.lastIndex = 0;
        aMatch = reCase.exec(sVal);
        trace(aMatch + " - " + reCase.lastIndex);
        reCase.lastIndex = 0;
        aMatch = reCase.exec(sVal);
        trace(aMatch + " - " + reCase.lastIndex);
        reCase.lastIndex = 0;
        aMatch = reCase.exec(sVal);
        trace(aMatch + " - " + reCase.lastIndex);


    }
  }
}

        








Related examples in the same category

1.read and write to this property to move the starting point of the next match
2.The lastMatch property is the string containing the last match made by the regular expression