string

非推奨を表示

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.

概要

関数

  • 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.

関数

byte

パラメータ

既定値: 1
既定値: i

戻り値

char

パラメータ

...: number

戻り値

find

パラメータ

pattern: string
init: number
既定値: 1
plain: boolean
既定値: false

戻り値

format

パラメータ

formatstring: string
...: string

戻り値

gmatch

パラメータ

pattern: string

戻り値

gsub

パラメータ

pattern: string
replacement: Variant
replacements: number

戻り値

パラメータ

戻り値

lower

パラメータ

戻り値

match

パラメータ

pattern: string
init: number
既定値: 1

戻り値

pack

パラメータ

format: string
...: Variant

戻り値

packsize

パラメータ

format: string

戻り値

パラメータ

戻り値

reverse

パラメータ

戻り値

split

パラメータ

separator: string
既定値: ,

戻り値

パラメータ

既定値: 1
既定値: -1

戻り値

unpack

パラメータ

format: string
data: string
readStart: string
既定値: 1

戻り値

upper

パラメータ

戻り値