stringlib¶
byte¶
Returns the internal numeric codes of the characters s[i], s[i+1], ..., s[j]
.
char¶
Returns a string with length equal to the number of arguments, in which each character has the internal numeric code equal to its corresponding argument.
dump¶
Returns a string containing a binary representation (a binary chunk) of the given function.
find¶
function string.find(s: string|number, pattern: string|number, init?: integer, plain?: boolean)
-> start: integer|nil
2. end: integer|nil
3. ...any
Looks for the first match of pattern
(see §6.4.1) in the string.
@return start
@return end
@return ...
— captured
format¶
Returns a formatted version of its variable number of arguments following the description given in its first argument.
gmatch¶
function string.gmatch(s: string|number, pattern: string|number, init?: integer)
-> fun():string, ...unknown
Returns an iterator function that, each time it is called, returns the next captures from pattern
(see §6.4.1) over the string s.
As an example, the following loop will iterate over all the words from string s, printing one per line:
gsub¶
function string.gsub(s: string|number, pattern: string|number, repl: string|number|function|table, n?: integer)
-> string
2. count: integer
Returns a copy of s in which all (or the first n
, if given) occurrences of the pattern
(see §6.4.1) have been replaced by a replacement string specified by repl
.
len¶
Returns its length.
lower¶
Returns a copy of this string with all uppercase letters changed to lowercase.
match¶
Looks for the first match of pattern
(see §6.4.1) in the string.
pack¶
function string.pack(fmt: string, v1: string|number, v2?: string|number, ...string|number)
-> binary: string
Returns a binary string containing the values v1
, v2
, etc. packed (that is, serialized in binary form) according to the format string fmt
(see §6.4.2) .
packsize¶
Returns the size of a string resulting from string.pack
with the given format string fmt
(see §6.4.2) .
rep¶
Returns a string that is the concatenation of n
copies of the string s
separated by the string sep
.
reverse¶
Returns a string that is the string s
reversed.
sub¶
Returns the substring of the string that starts at i
and continues until j
.
unpack¶
Returns the values packed in string according to the format string fmt
(see §6.4.2) .
upper¶
Returns a copy of this string with all lowercase letters changed to uppercase.