字符串参数组合:
方法:
public static function substring(str:String, ...rest):String
{
if (!str) {
return "";
}
var len:uint = rest.length;
var args:Array;
if (len == 1 && rest[0] is Array) {
args = rest[0] as Array;
len = args.length;
trace("len",len);
} else {
args = rest;
}
trace("length::",args.length,len == 1,rest[0] is Array);
for (var i:int = 0; i < len; i++) {
str = str.replace(new RegExp("\\{"+i+"\\}", "g"), args[i]);
}
return str;
}
文档类:
var str:String = StringConstant.substring("连接字符{0}再连接{1}","111","222");
trace(str);
时间: 2024-09-28 05:03:25