Added append() and prepend().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4359 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-09-07 21:30:11 +00:00
parent e88abe3751
commit 0ed50738a9
+26
View File
@@ -43,6 +43,32 @@ public class StringUtil
return (str.lastIndexOf(substr, 0) == 0);
}
/**
* Append 0 or more copies of the padChar String to the input String
* until it is at least the specified length.
*/
public static function pad (
str :String, length :int, padChar :String = " ") :String
{
while (str.length < length) {
str += padChar;
}
return str;
}
/**
* Prepend 0 or more copies of the padChar String to the input String
* until it is at least the specified length.
*/
public static function prepad (
str :String, length :int, padChar :String = " ") :String
{
while (str.length < length) {
str = padChar + str;
}
return str;
}
/**
* Utility function that strips whitespace from the ends of a String.
*/