flex 中的 trim 方法
public static function trim(str:String):String
{
if (str == null) return '';
var startIndex:int = 0;
while (isWhitespace(str.charAt(startIndex)))
++startIndex;
var endIndex:int = str.length - 1;
while (isWhitespace(str.charAt(endIndex)))
--endIndex;
if (endIndex >= startIndex)
return str.slice(startIndex, endIndex + 1);
else
return "";
}
public static function isWhitespace(character:String):Boolean
{
switch (character)
{
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return true;
default:
return false;
}
}
该方法在 StringUtil 类中