xen::string
Provides utilities for working with strings. All of the available functions in this namespace are also available as member functions to string objects.
include string;
Public Functions
len
len (str: string) -> number
Returns the number of characters in the string.
upper
upper (str: string) -> string | null
Converts the given string to UPPERCASE.
lower
lower (str: string) -> string | null
Converts the given string to lowercase.
substr
substr (str: string, start: number, end: number) -> string | null
Returns a substring taken from the source string at [ str[start], str[end] ].
find
find (str: string, needle: string) -> number | null
Find the given substring (needle) in the source string. Returns the index of the last matched character.
trim
trim (str: string) -> string | null
Removes whitespace from the given string.
contains
contains (str: string, needle: string) -> bool | null
Returns whether the given substring (needle) exists within the source string.
starts_with
starts_with (str: string, prefix: string) -> bool | null
Returns whether the given source string starts with the given prefix.
ends_with
ends_with (str: string, suffix: string) -> bool | null
Returns whether the given source string ends with the given suffix.
split
split (str: string, split_on: string) -> [string] | null
Splits the source string at the given split token and returns an array of strings.
replace
replace (str: string, old_str: string, new_str: string) -> [string] | null
Replaces old_str in src with new_str.