Skip to content

String

string match ( regex pattern, string target )

Returns the first substring of string to match pattern.
If pattern does not match string, it returns an empty string.


string join ( array target, string separator = "" )

Runs str on each element of target, separating each element by separator, and combines all to a single string.


bool prefix? ( string target, string prefix )

Returns a boolean value, whether target begins with prefix.


bool suffix? ( string target, string suffix )

Returns a boolean value, whether target ends with suffix.


string repeat ( string target, int count )

Returns a string, with target repeated count times.


string upper ( string target )

Returns target, converted to upper case.


string lower ( string target )

Returns target, converted to lower case.


string trim ( string target )

Returns target, with whitespace removed from the left and right.


string ltrim ( string target )

Returns target, with whitespace removed from the left.


string rtrim ( string target )

Returns target, with whitespace removed from the right.


string squeeze ( string target, string? characters )

Returns target, with all repeated characters collapsed into one.
If characters is provided, it only collapses repeated characters contained in characters.


string replace ( string target, string match, string substitute, int count = -1 )

Returns target but with count instances of substring match replaced with substitute, in left to right order.

If count is negative, it will replace all matching substrings.


array split ( string target, string match )

Splits target on each instance of substring match.


string lpad ( string target, int size, string padding = " " )

If the size of target is less than size, it returns target but padded with characters from padding at the start.


string rpad ( string target, int size, string padding = " " )

If the size of target is less than size, it returns target but padded with characters from padding at the end.