handycam
08-12-2007, 12:05 AM
I've got a string where I need to replace multiple instances of a word with a string.
A simpler example would be "Four score and # years ago" -- where I need to insert a string variable instead of "#".
I have been doing something like:
var re : RegExp = /(#+)/ ;
var _results:Array = _myString.split(re);
trace(_results);
And my plan was to use "results.splice()" to add the string. However, in the real string there are several "#" to replace, and it seems my way would get unwieldy.
Is there a more efficient way?
A simpler example would be "Four score and # years ago" -- where I need to insert a string variable instead of "#".
I have been doing something like:
var re : RegExp = /(#+)/ ;
var _results:Array = _myString.split(re);
trace(_results);
And my plan was to use "results.splice()" to add the string. However, in the real string there are several "#" to replace, and it seems my way would get unwieldy.
Is there a more efficient way?