Use lastIndexOf to search string
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.lastIndexOf( "cool" );
if ( index != -1 ) {
trace( "String contains word cool at index " + index );
}
index = example.lastIndexOf( "cool", index - 1 );
if ( index != -1 ) {
trace( "String contains word cool at index " + index );
}
}
}
}
Related examples in the same category