string

Veraltete anzeigen

The string library provides generic functions to manipulate strings, such as to extract substrings or match patterns. You can access the string library by the global string library.

See String pattern reference for details on using string.match(), string.gmatch(), and string.gsub() to find (and replace) substrings.

Zusammenfassung

Funktionen

  • Returns the internal numerical codes of the characters s[i], s[i+1], ..., s[j]. The default value for i is 1; the default value for j is i. These indices are corrected following the same rules of function string.sub.

  • Receives zero or more integers and 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.

  • find(s : string,pattern : string,init : number,plain : boolean):number,number

    Looks for the first match of pattern in the string s and returns the indices of s where the occurrence starts and ends.

  • format(formatstring : string,... : string):string

    Returns a formatted version of its variable number of arguments following the description given in its first argument, which must be a string.

  • gmatch(s : string,pattern : string):function

    Returns an iterator function that returns the next captures from pattern over the string s each time it's called.

  • gsub(s : string,pattern : string,replacement : Variant,replacements : number):string,number

    Returns a copy of s in which all or the first n occurrences of the pattern are replaced with the given replacement. The second value returned is the total number of substitutions made.

  • Returns the length of a string.

  • Returns a copy of a string with all uppercase letters changed to lowercase.

  • match(s : string,pattern : string,init : number):string

    Looks for the first match of pattern in the string s. If a match is found, it is returned; otherwise, it returns nil. A third, optional numerical argument, init, specifies where to start the search.

  • pack(format : string,... : Variant):string

    Returns a binary string containing the provided arguments.

  • Returns the size in bytes of any string packed with a given description.

  • Returns a string that is the concatenation of n copies of the string s.

  • Returns a string that is the string s reversed.

  • split(s : string,separator : string):table

    Splits a string into parts based on the defined separator character(s), returning a table of ordered results.

  • Returns the substring of s that starts at i and continues until and including j. i and j can be negative. i defaults to 1 and j defaults to -1.

  • unpack(format : string,data : string,readStart : string):Tuple

    Extracts the values packed in the provided binary string.

  • Returns a copy of a string with all lowercase letters changed to uppercase.

Funktionen

byte

Parameter

Standardwert: 1
Standardwert: i

Rückgaben

char

Parameter

...: number

Rückgaben

find

Parameter

pattern: string
init: number
Standardwert: 1
plain: boolean
Standardwert: false

Rückgaben

format

Parameter

formatstring: string
...: string

Rückgaben

gmatch

Parameter

pattern: string

Rückgaben

gsub

Parameter

pattern: string
replacement: Variant
replacements: number

Rückgaben

Parameter

Rückgaben

lower

Parameter

Rückgaben

match

Parameter

pattern: string
init: number
Standardwert: 1

Rückgaben

pack

Parameter

format: string
...: Variant

Rückgaben

packsize

Parameter

format: string

Rückgaben

Parameter

Rückgaben

reverse

Parameter

Rückgaben

split

Parameter

separator: string
Standardwert: ,

Rückgaben

Parameter

Standardwert: 1
Standardwert: -1

Rückgaben

unpack

Parameter

format: string
data: string
readStart: string
Standardwert: 1

Rückgaben

upper

Parameter

Rückgaben