Force the last index to be past the first matching position : Match « Regular Expressions « Flash / Flex / ActionScript






Force the last index to be past the first matching position

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var regex:RegExp = /\b[a-z]{3}\b/g;
        var sentence:String = "This string has two three letter words.";
        
        trace( sentence.search( regex ) );
        trace( regex.lastIndex );
        trace( sentence.search( regex ) );
        regex.lastIndex = 13;
        trace( sentence.search( regex ) );
        trace( regex.lastIndex );

    }
  }
}

        








Related examples in the same category

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