Replace Characters in a String AS3

Using split() and join() you can strip or insert characters into strings very easily.

The below function can be called to do just that.

/// Replaces characters in a string.
public static function replaceChars(targetString:String, charactersToStrip:String, replacementCharacters:String = "")
{
  targetString = targetString.split(charactersToStrip).join(replacementCharacters);
  return targetString;
}
Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑