-
var letterA:String = "a";
-
var letterZ:String = "z";
-
-
trace(letterA.localeCompare(letterZ));
-
trace(letterZ.localeCompare(letterA));
-
/*
-
outputs
-
-25
-
25
-
*/
String.localeCompare() calculates the sorting order between two Strings....
String.localeCompare() calculates the sorting order between two Strings....
indexOf() searches a string for another string and returns an index... in line 3 above, I search the words string for the smaller string "two" and indexOf() gives me the index of the letter "t". If indexOf() doesn't find anything it will return -1 (as in the case of line 9).
I seem to recall using this in some unexpected places. I'll see if I can dig up an example over the next few days.
The above animates a zig zag pattern in a TextField.
Not ActionScript, but the coolest thing I've seen in Mysql in awhile, the soundex function will convert a string into a soundex index... read more about it on wikipedia.
I did some tests and it matches things like:
what's your name? & whats yer name
very cool... since this isn't ActionScript, I will post another snippet right after this.
UPDATE: Actually started reading more about this stuff and dug up some algorithms... metaphone etc... fun stuff, maybe I'll port some of it to actionscript...