as3.0去除空格


                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(/([  ]{1})/g,"");
                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(//g,"");
                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(//g,"");
                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(//g,"");
                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(//g,"");
                FouthFrame.answerArr[j] = FouthFrame.answerArr[j].replace(/,/g,"");

 

var str:String="是 我们 呀CuPlay   er.com网站"

function trim(string:String):String {
 return string.replace(/([  ]{1})/g,"");
}
trace(trim(str))

//[  ]内是一个中文空格一个英文空格
//{1}是说匹配一个到多个
///g是说可连续匹配
//去空格,实际上就是把空格替换成空字符串

 

posted on 2018-06-12 15:11  zqiang0803  阅读(814)  评论(0编辑  收藏  举报

导航