Prepends padstr
to str
until it reaches specified length.
trace(string_lpad(string(42), "0", 4)); // "0042"
The following are built-in:
The following are NTT-specific additions:
Prepends padstr
to str
until it reaches specified length.
trace(string_lpad(string(42), "0", 4)); // "0042"
Appends padstr
to str
until it reaches specified length.
trace(string_rpad(string(42), "0", 4)); // "4200"
Converts a number to a string with automatic precision
(unlike string_format
, which requires specifying the number of decimal places).
trace(string_auto(0.4)); // "0.4" trace(string_auto(0.4040)); // "0.404"
Removes leading and trailing spaces from a string.
trace(string_trim(" hi ")); // "hi"
Same as now-built-in string_trim
.
Removes leading spaces from a string.
trace(string_trim(" hi ")); // "hi "
Same as now-built-in string_trim_start
.
Removes trailing spaces from a string.
trace(string_trim(" hi ")); // " hi"
Same as now-built-in string_trim_end
.
Splits a string on delimiter into an list of strings.
If list
is provided, clears it and adds items to it, otherwise makes a new list.
Returns the list.
If the string does not contain the delimiter, returns a 1-element array with the entire string.
var list = string_split_list("A|B|C", "|"); trace(list[|1]); // "B"
Returns a SHA-1 hash of a string, assuming Unicode encoding.
Returns a SHA-1 hash of a string, assuming UTF-8 encoding.
Returns a MD5 hash of a string, assuming Unicode encoding.
Returns a MD5 hash of a string, assuming UTF-8 encoding.
Also see: string_load, string_save.