Find and Replace AS2
A nice simple function to find and replace characters in a string using actionscript 2. This is perfect if you want to replace words or even remove words/characters from a string.
function stringReplace(myString:String, findThis:String, replaceThis:String):String{
return myString.split(findThis).join(replaceThis);
}
myString = "example-of-some-words-with-dashes"
/////Strip out all of the dashes by replacing -'s with nothing
myString = stringReplace(linkname, "-", "");
trace(myString)
Tags: actionscript, code, flash
This entry was posted on Friday, February 19th, 2010 at 3:53 pm and is filed under ActionScript & Flash. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.