Use offset index in indexOf method to search substring : IndexOf lastIndexOf : String Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » String » IndexOf lastIndexOf »

 

Use offset index in indexOf method to search substring


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:String = "This string contains the word cool twice. Very cool.";
        var index:int = example.indexOf"cool" );
        
        if index != -) {
          trace"String contains word cool at index " + index );
        }
        
        index = example.indexOf"cool", index + );
        
        if index != -) {
          trace"String contains word cool at index " + index );
        }

    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo String
» IndexOf lastIndexOf