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:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user