String


 * This article is about the Lua type. For the API, see String API.

String is a type that represents an immutable sequence of characters. For a list of string-related functions, see String API.

Literal value
Strings can be used in a program's source code by using a string literal, which is typically indicated by enclosing the desired sequence of characters within a pair of single or double quotes:

Value escaping
To use characters such as a newline, the delimiter used to open/close the literal ( or  ), or to specify specific characters by their numeric code (Char 20 == Space), such values must be prepended with a backslash, and to use a backslash literally, escape it with another backslash:

Multiline literals
The above method of expressing a string literal is for single-line usage only, for a multi-line string literal, begin the sequence with and terminate it with :

One thing to note is that when using the multiline literal, Lua will ignore the first newline if nothing follows the initial, but not the trailing :

Additionally, inside of a multiline string, all values are escaped by default, so using characters like  and   will represent themselves instead of acting specially: