Contact ZenDuo


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: , ,

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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>