dcsext.string
String - extensions to lua strings
Contents
Functions
_t.firstToUpper(str)
Uppercase the first letter of string.
Parameters
- str
- A string
Returns
- A string, with the first letter uppercased.
_t.interp(s, tab)
String interpolation. Substitutes name between two percent signs from tab. string enclosed with parenthesis with a value in tab. tab is a table of name=value pairs.
Parameters
- s
- string with possible substitution keys.
- tab
- table of name=value pairs used in the substitution.
Returns
- [string] expanded with substitutions.
_t.join(tbl, sep)
Join an array of typically strings into a single string seperated by sep.
Parameters
- tbl
- A table of typically strings
- sep
- seperator string to use
Returns
- A string
_t.split(str, sep)
Split str string searching str for spe substring to split on. Return a array of the resulting substrings.
Parameters
- str
- string to split
- sep
- seperator substring to split the string on, this sequence of characters will not exist in the resultant substrings.
Returns
- array of split strings
_t.startsWith(haystack, needle)
Does a string start with a given substring?
Parameters
- haystack
- the string
- needle
- the substring to look for
Returns
- True if it starts with needle, false otherwise
_t.trim(str)
Trim withspace from the beginning and end of str.
Parameters
- str
- A string
Returns
- a trimmed string