String API
|
|||||||||||
Return the byte of the first character in the given str. As string literals in Lua represent ASCII strings, this will most likely return ASCII codepoints. To convert a byte back into a string, use string.char. | |||||||||||
Syntax | string.byte(
Colon notation: str:byte() |
||||||||||
Returns | number | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
|
|||||||||||
Creates a string containing only the byte num. Hence, the number passed must be at least 0 and at most 255, and will be floored to the nearest integer. | |||||||||||
Syntax | string.char(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
|
|||||||||||
Converts a function to a binary representation which can later be converted back to a function using loadstring. Functions not defined in Lua code (i.e. native CC functions such as type, pcall and os.date) cannot be dumped. Upvalues (local variables defined outside of a function and used within it) are not preserved. | |||||||||||
Syntax | string.dump(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
| |||||||||||
| |||||||||||
|
|
|||||||||||
Finds a pattern in a sentence. | |||||||||||
Syntax | string.find(
Colon notation: sentence:find(
|
||||||||||
Returns | number | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
|
|
|||||||||||
Replaces placeholder strings in a string with the specified arguments. | |||||||||||
Syntax | string.format(
|
||||||||||
Returns | string output | ||||||||||
Part of | Lua | ||||||||||
API | string | ||||||||||
| |||||||||||
|
String.gmatch
|
|||||||||||
Replaces a string in a sentence. | |||||||||||
Syntax | string.gsub(
Colon notation: sentence:gsub(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
| |||||||||||
|
|
|||||||||||
Return the number of bytes in str.
The number of bytes in a string is not necessarily equivalent to its amount of characters! Many Unicode characters take up more than one byte. For example,
string.len("รถ") returns 2 . Hence, string.len only returns the amount of characters if str is encoded in an encoding that only uses one byte per character, such as ASCII.#str . |
|||||||||||
Syntax | string.len(
Colon notation: str:len() |
||||||||||
Returns | number | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
|
|||||||||||
Return a modified version of str where all uppercase characters have been converted to lowercase. Special characters and numbers are not affected. | |||||||||||
Syntax | string.lower(
Colon notation: str:lower() |
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
String.match
|
|||||||||||
Return the given str repeated repeat times. | |||||||||||
Syntax | string.rep(
Colon notation: str:rep(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
|
|||||||||||
Return the given str with the character order reversed. | |||||||||||
Syntax | string.reverse(
Colon notation: str:reverse() |
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
|
|||||||||||
Return a string including the characters from start to end within str inclusively. If the arguments are negative, the character count will wrap the other way around. If the last argument end is not given, the substring will end at the end of the initial string. | |||||||||||
Syntax | string.sub(
Colon notation: str:sub(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
| |||||||||||
|
|
|||||||||||
Return a modified version of str where all lowercase characters have been converted to uppercase. Special characters and numbers are not affected. | |||||||||||
Syntax | string.upper(
Colon notation: str:upper() |
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | string | ||||||||||
|
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.