Luawe the Wayfarer Engine's scripting language All pages

string

Text. Every string also has these as its own: ("hello"):upper(), name:sub(1, 3).

string.len

string.len(s)

How many bytes long a string is (the same as #s). For letters of any language, utf8.len.

string.sub

string.sub(s, from, to?)

The part of a string from one place to another (counted from 1; negative: from its end).

string.upper

string.upper(s)

The string in capital letters (a to z).

string.lower

string.lower(s)

The string in small letters (A to Z).

string.rep

string.rep(s, n, separator?)

The string n times over, with the separator between.

string.reverse

string.reverse(s)

The string backwards.

string.byte

string.byte(s, from?, to?)

The numbers of the bytes from one place to another (the first one, with no places).

string.char

string.char(...)

A string made of bytes with these numbers (0 to 255).

string.format

string.format(format, ...)

A string made to a pattern: %d a whole number, %.2f a number with two decimals, %s anything as a string, %5s padded to 5, %x hexadecimal, %% a percent sign.

string.find

string.find(s, pattern, from?, plain?)

Where a pattern first matches in a string: where it starts and ends, then what its brackets caught; nil when it doesn't. plain: look for the very text, not a pattern.

string.match

string.match(s, pattern, from?)

What a pattern's brackets catch in a string (the whole match, when it has none); nil when it doesn't match.

string.gmatch

string.gmatch(s, pattern)

For a for loop: every match of a pattern in a string, one after the other.

string.gsub

string.gsub(s, pattern, replacement, limit?)

The string with every match of a pattern replaced: by a string (%1 is what the first bracket caught), by what a table has for it, or by what a function gives. Also gives how many it replaced.

string.split

string.split(s, separator?)

A list of the pieces of a string between separators (a comma, when none is given; "" cuts it into letters).

string.trim

string.trim(s)

The string without the spaces at its ends.