77
6.1.19. Data Serialization
serialize.encode (value)
Generates a storable representation of a value.
serialize.decode (value)
Creates a Lua value from a stored representation.
6.1.20. String functions
This library provides generic functions for string manipulation, such as finding and extracting
substrings, and pattern matching. When indexing a string in Lua, the first character is at
position 1 (not at 0, as in C).
Indices are allowed to be negative and are interpreted as indexing backwards, from the end of
the string. Thus, the last character is at position -1, and so on.
The string library provides all its functions inside the table string. It also sets a meta table for
strings where the __index field points to the string table. Therefore, you can use the string
functions in object-oriented style. For instance, string.byte(s, i) can be written as s:byte(i).The
string library assumes one-byte character encodings.
string.trim (str)
Trims the leading and trailing spaces off a given string.
string.split (str, sep)
Splits string by given separator string. Returns Lua table.
string.byte (s [, i [, j]])
Returns the internal numerical codes of the characters . The default value for i
is 1;the default value for j is i.Note that numerical codes are not necessarily portable across
platforms.
string.char (···)
Receives zero or more integers. Returns a string with length equal to the number of arguments,
in which each character has the internal numerical code equal to its corresponding argument.
Note that numerical codes are not necessarily portable across platforms.
string.find (s, pattern [, init [, plain]])
Looks for the first match of pattern in the string s. If it finds a match, then find returns the
indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional
numerical argument init specifies where to start the search; its default value is 1 and can be
negative. A value of true as a fourth, optional argument plain turns off the pattern matching
facilities, so the function does a plain "find substring" operation, with no characters in pattern
being considered "magic". Note that if plain is given, then init must be given as well. If the
pattern has captures, then in a successful match the captured values are also returned, after
the two indices.