StringUtil.trimEnd()

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5215 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Tom Conkling
2008-07-01 23:12:45 +00:00
parent 2cfb546015
commit c648bfb346
+17 -4
View File
@@ -21,11 +21,11 @@
package com.threerings.util {
import com.threerings.util.env.Environment;
import flash.utils.ByteArray;
import flash.utils.Dictionary;
import com.threerings.util.env.Environment;
public class StringUtil
{
/**
@@ -237,7 +237,7 @@ public class StringUtil
}
/**
* Utility function that strips whitespace from the ends of a String.
* Utility function that strips whitespace from the beginning and end of a String.
*/
public static function trim (str :String) :String
{
@@ -256,6 +256,19 @@ public class StringUtil
}
}
/**
* Utility function that strips whitespace from the end of a String.
*/
public static function trimEnd (str :String) :String
{
var endIdx :int = str.length - 1;
while (isWhitespace(str.charAt(endIdx))) {
endIdx--;
}
return (endIdx >= 0 ? str.slice(0, endIdx + 1) : "");
}
/**
* @return true if the specified String is == to a single whitespace character.
*/
@@ -493,7 +506,7 @@ public class StringUtil
str += "\n";
}
return str;
}