Tuesday, December 22, 2009

ReplaceAll() or .Replace()

SomeString.Replace() only replaces the first instance of the string it finds. Use the following code to replace all instances.


private function replaceAll(org:String, fnd:String, rpl:String):String
{
return org.split(fnd).join(rpl);
}


split and join out performs .replace()

thanks to snipplr

No comments: