stringライブラリ

ライブラリ日本語解説あり

ひとことで言うと

文字列を扱うためのライブラリです。文字数を数える・一部を取り出す・大文字にする・検索する、などができます。

公式の説明(英語):Provides generic functions to manipulate strings.

関数(17)

名前と書き方説明
byte
string.byte(s: string, i: number, j: number): int
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.
char
string.char(...: int): string
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
string.find(s: string, pattern: string, init: number, plain: bool): 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
string.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
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
string.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.
len
string.len(s: string): int
文字列の長さ(バイト数)を返します。Returns the length of a string.
lower
string.lower(s: string): string
小文字にします。Returns a copy of a string with all uppercase letters changed to lowercase.
match
string.match(s: string, pattern: string, init: number): string
Looks for the first match of pattern in the string s.
pack
string.pack(format: string, ...: Variant): string
Returns a binary string containing the provided arguments.
packsize
string.packsize(format: string): number
Returns the size in bytes of any string packed with a given description.
rep
string.rep(s: string, n: int): string
文字列をくりかえします。Returns a string that is the concatenation of n copies of the string s.
reverse
string.reverse(s: string): string
Returns a string that is the string s reversed.
split
string.split(s: string, separator: string): table
区切り文字で分けて配列にします。Splits a string into parts based on the defined separator character(s), returning a table of ordered results.
sub
string.sub(s: string, i: int, j: int): string
文字列の一部を取り出します。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
string.unpack(format: string, data: string, readStart: string): Tuple
Extracts the values packed in the provided binary string.
upper
string.upper(s: string): string
大文字にします。Returns a copy of a string with all lowercase letters changed to uppercase.

stringを使う記事

英語の説明とメンバーの一覧は、Roblox Creator Documentation(string)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む