Currently, .replace method of the string objects is supposed to replace all occurrences, but replaces only the first one. It is probably a bug:
In the same time, this unintended behavior can be actually useful. Many other programming languages use a count parameter of the string replacement method or implement two methods. Some examples: Python has a count parameter string.replace(), Java implements two methods String.replaceFirst() and String.replaceAll(), C# has a count parameter in Regex.Replace(), Javascript allows both by accepting regular expressions as search objects.
In Flexscript there are only two options:
- use stringreplace() to replace all occurences
- abuse the bug in .replace() method to replace only the first one
The second option is not particularly elegant. I suppose either the method or the documentation should be fixed, and the complementary method or an optional count parameter should be added.