as3 去掉字符串两边的空格,换行符,方法一
ActionScript Code
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public function trim(char:String):String{
if(char == null){ return null; } return rtrim(ltrim(char)); } private function ltrim(char:String):String{ if(char == null){ return null; } var pattern:RegExp = /^\s*/; return char.replace(pattern,""); } private function rtrim(char:String):String{ if(char == null){ return null; } var pattern:RegExp = /\s*$/; return char.replace(pattern,""); } |
去除掉空格,方法二
ActionScript Code
1
|
})/g,"");
|