After many years, 'replace' method came along in String class of ActionScript 3. But, not many folks were happy. Because, in ActionScript 3, string.replace(arg1, arg2), replaces only the first occurrence of the arg1 with arg2.
In order to perform a ‘replace all’ operation use
The 'g' is just a handle to specify that all occurrences of the string arg1 need to be replaced
strTarget.replace(/arg1/g, arg2);
or
Point to note here is that, in the both the methods, traditional 'replace' & the 'split-join' method arg1 can be of type string or a regular expression as the need be.
strTarget.split(arg1).join(arg2);
Point to note here is that, in the both the methods, traditional 'replace' & the 'split-join' method arg1 can be of type string or a regular expression as the need be.