martedì, agosto 11, 2009

Actionscript 3: Checking Whether a String Contains Another String

I just ran across some great ActionScript string examples at Foundation Flash. I highly recommend reading the entire entry. I’m pasting a portion of it here so I can find it easily again:

var masterString:String = "Foundation Flash is great, all others are rubbish";
trace(String(masterString.indexOf("bad")));
//traces "-1" i.e. not found
trace(String(masterString.indexOf("great")));
//traces "20" i.e. found
trace(String(masterString.indexOf("great",26)));
//traces "-1" i.e. not found (after the 26th character (','))
trace(String(masterString.indexOf("Foundation")));
// traces "0"
trace(String(masterString.indexOf("flash")));
//traces "-1" i.e. not found
trace(String(masterString.toLowerCase().indexOf("flash")));
//traces "11" i.e. found

2 Comments:

Anonymous Anonimo said...

Easily I agree but I contemplate the list inform should secure more info then it has.

12/27/2009 5:52 AM  
Anonymous Anonimo said...

Good brief and this post helped me alot in my college assignement. Thanks you as your information.

12/29/2009 8:51 AM  

Posta un commento

<< Home