6.4 – String Manipulation

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 metatable 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.rep()

string.rep (s, n [, sep])nssepsepn (Note that it is very easy to exhaust the memory of your machine with a single

2017-02-21 04:16:08
string.gmatch()

string.gmatch (s, pattern)pattern§6.4.1spattern As

2017-02-21 04:16:03
string.upper()

string.upper (s)

2017-02-21 04:16:11
Patterns

6.4.1 – Patterns Patterns in Lua are described by regular strings, which are interpreted as patterns by the pattern-matching functions

2017-02-21 04:15:42
Format Strings for Pack and Unpack

6.4.2 – Format Strings for Pack and Unpack The first argument to string.pack

2017-02-21 04:11:08
string.dump()

string.dump (function [, strip]) Returns a string containing a binary representation (a binary chunk) of the given function, so that a later

2017-02-21 04:16:00
string.sub()

string.sub (s, i [, j])sijijjstring.sub(s,1,j)sjstring.sub(s

2017-02-21 04:16:10
string.byte()

string.byte (s [, i [, j]])s[i]s[i+1]s[j]iji

2017-02-21 04:15:59
string.find()

string.find (s, pattern [, init [, plain]]) Looks for the first match of pattern (see

2017-02-21 04:16:01
string.gsub()

string.gsub (s, pattern, repl [, n])snpattern§6.4.1

2017-02-21 04:16:04