// 使用正则表达式,判断参数是否为整数 // 是整数就返回true,不是就返回false function isInteger(char:String):Boolean{ if(char == null){ return false; } char = trim(char); var pattern:RegExp = /^[-\+]?\d+$/; var result:Object = pattern.exec(char); if(result == null) { return false; } return true; } // 去除参数中的前后空格 function trim(char:String):String{ if(char == null){ return null; } return rtrim(ltrim(char)); } function ltrim(char:String):String{ if(char == null){ return null; } var pattern:RegExp = /^\s*/; return char.replace(pattern,""); } function rtrim(char:String):String{ if(char == null){ return null; } var pattern:RegExp = /\s*$/; return char.replace(pattern,""); }