Expand description
Standard library for string operations and pattern-matching.
Port of lstrlib.c (Lua 5.4.7, 1875 lines, 46 functions).
Sections:
- Basic string operations (byte, char, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper)
- Pattern-matching engine (MatchState + recursive matcher)
- String format (
string.format) - Pack / unpack (
string.pack,string.packsize,string.unpack) - Module registration (
luaopen_string)
Constants§
- STRING_
LIB - Function table for
stringlibrary. - STRING_
META_ METHODS - Metamethods to install on the string metatable.
Functions§
- arith_
add - arith_
div - arith_
idiv - arith_
mod - arith_
mul - arith_
pow - arith_
sub - arith_
unm - createmetatable
- Create the string metatable and set it as the metatable for all strings.
- gmatch
string.gmatch(s, pattern [, init])— return an iterator for all matches.- gmatch_
aux - Continuation function for
string.gmatchiterator closure. - luaopen_
string luaopen_string— open the string library.- str_
byte string.byte(s [, i [, j]])— return numeric codes of characters.- str_
char string.char(...)— return string built from character codes.- str_
dump string.dump(function [, strip])— serialize a function as binary chunk.- str_
find string.find(s, pattern [, init [, plain]])— find pattern ins.- str_
format string.format(fmt, ...)— C-style string formatting.- str_
gsub string.gsub(s, pattern, repl [, n])— global substitution.- str_len
string.len(s)— return byte-length ofs.- str_
lower string.lower(s)— return lowercase copy.- str_
match string.match(s, pattern [, init])— match pattern againsts.- str_
pack string.pack(fmt, ...)— pack values into a binary string.- str_
packsize string.packsize(fmt)— return the byte-size the format would produce.- str_rep
string.rep(s, n [, sep])— returnncopies ofsseparated bysep.- str_
reverse string.reverse(s)— return string with bytes reversed.- str_sub
string.sub(s, i [, j])— return substring.- str_
unpack string.unpack(fmt, s [, pos])— unpack binary data from string.- str_
upper string.upper(s)— return uppercase copy.