dcsex.string

String - extensions to lua strings

Contents

  1. Functions
    1. _t.firstToUpper(str)
    2. _t.interp(s, tab)
    3. _t.join(tbl, sep)
    4. _t.split(str, sep)
    5. _t.startsWith(haystack, needle)
    6. _t.trim(str)

Functions

_t.firstToUpper(str)

Parameters

str
A string

Returns

  • A string, with the first letter uppercased.

_t.interp(s, 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)

Parameters

tbl
A table of typically strings
sep
seperator string to use

Returns

  • A string

_t.split(str, sep)

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)

Parameters

haystack
the string
needle
the substring to look for

Returns

  • True if it starts with needle, false otherwise

_t.trim(str)

Parameters

str
A string

Returns

  • a trimmed string