String.replace() method for ActionScript2
Another snippet for free — String.replace() prototype for Flash that can be used to replace a pattern in a String.
The code of the String.replace() prototype is very simple and somewhat similar to the PHP's str_replace function:
Example:
// initial string with a placeholder
var str:String = '$person is welcome to flash tekkie';
// replace $person with 'Flash developer' and trace it
var replacedStr:String = str.replace('$person','Flash developer');
trace(replacedStr);
As seen above method takes 2 arguments. Firstly a string pattern to search for and secondly a string to replace the pattern(s) found. Method returns a String.