as3 去掉字符串空白问题

去掉内容的所有空白

function trim(str:String):String {
 return str.replace(/([  ]{1})/g,"");
}
//[  ]内是一个中文空格一个英文空格
{1}是说匹配一个到多个
/g是说可连续匹配
去空格,实际上就是把空格替换成空字符串

去掉首尾空白

str=str.replace(/^s+|s+$/g,'');
原文地址:https://www.cnblogs.com/dt1991/p/8565302.html