There is a function String.replace() which returns the result string. But note, this only replaces the first occurance of given string/expression!
So, to actually replace all the occurances of given string/expression, you must loop through until all the matches are replaced. Code & Documentation
However, there is another easy customized function to automatically replace all the occurance of given match. Here goes the customized function:
public function str_replace(mainStr:String, str1:String, str2:String):String { var temp:Array = mainStr.split(str1); var tempStr:String = temp.join(str2); return tempStr; }
Usage:
var myStr:String = str_replace("a_b_c", "_" , "1"); // a1b1c1
Got Help From Source