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 != -1 ) { trace( "String contains word cool at index " + index ); }
index = example.indexOf( "cool", index + 1 );
if ( index != -1 ) { trace( "String contains word cool at index " + index ); }
} } }
Related Scripts with Example Source Code in same category :