Trace the index : Match « Regular Expressions « Flash / Flex / ActionScript






Trace the index

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var example:RegExp = /abc/;

        var result:Array = example.exec( "A string with abc in it" );
        
        trace( result );
        trace( result.index );
        
        result = example.exec( "A string with no match" );
        
        trace( result );
    }
  }
}

        








Related examples in the same category

1.Create a pattern to match against a string
2.Create a global regex to match multiple times in a string
3.Create a regular expression that matches three-letter words
4.Looking for Pattern Matches
5.Create a global regular expression that matches three-letter words
6.Force the last index to be past the first matching position
7.Creating a Nongreedy Pattern
8.Return simply whether the string matches the pattern at all.