
Код AS3:
public static function substitute(str:String, ... rest):String
{
if (str == null) return '';
// Replace all of the parameters in the msg string.
var len:uint = rest.length;
var args:Array;
if (len == 1 && rest[0] is Array)
{
args = rest[0] as Array;
len = args.length;
}
else
{
args = rest;
}
for (var i:int = 0; i < len; i++)
{
str = str.replace(new RegExp("\\{"+i+"\\}", "g"), args[i]);
}
return str;
}
На AS2 сами, ручками.