File StringUtils.lua
-- String Utils -- --
Functions
string.enclose (s, maxlevel) | Enclose string by long brackets. |
string.ends (String, Suffix) | Test if string is ending with specified suffix. |
string.starts (String, Prefix) | Test if string is starting with specified prefix. |
string:split (delimiter) | Splits a string into a table by the given delimiter. |
string:title () | Capitalize first character in a string. |
Functions
- string.enclose (s, maxlevel)
-
Enclose string by long brackets.
TODO what is purpose of this function?Parameters
- s:
- maxlevel:
- string.ends (String, Suffix)
-
Test if string is ending with specified suffix.
Parameters
- String:
- Suffix:
See also:
- string.starts (String, Prefix)
-
Test if string is starting with specified prefix.
Parameters
- String:
- Prefix:
See also:
- string:split (delimiter)
-
Splits a string into a table by the given delimiter.
Parameters
- delimiter:
Usage:
-
names = "Alice, Bob, Peter" name_table = {} name_table = names:split(", ") display(name_table)
Previous code will print out:table { 1: 'Alice' 2: 'Bob' 3: 'Peter' }
Return value:
- array with split strings
- string:title ()
-
Capitalize first character in a string.
Usage
- Variable testname is now Anna.
testname = string.title("anna")
- Example will set test to "Bob".
test = "bob" test = string.title(test)
- Variable testname is now Anna.