Class String
String metatype, wrapper for godot_string
.
Construct using the idiom String(...)
, which calls __new.
It is compatible with Lua's string library API.
Methods
String:begins_with (s) | Returns true if the String begins with the given string. |
String:bigrams () | Returns the bigrams (pairs of consecutive letters) of this string. |
String:c_escape () | Returns a copy of the string with special characters escaped using the C language standard. |
String:c_escape_multiline () | Returns a copy of the string with the special characters \ and " escaped using the C language standard. |
String:c_unescape () | Returns a copy of the string with escaped characters replaced by their meanings. |
String:camelcase_to_underscore ([lowercased=true]) | Returns a copy of String with Camel cased words separated by underscores. |
String:capitalize () | Changes the case of some letters. |
String:casecmp_to (s) | Performs a case-sensitive comparison to another string. |
String:count (what[, from=0[, to=0]]) | Returns the number of occurrences of substring what between from and to positions. |
String:countn (what[, from=0[, to=0]]) | Returns the number of occurrences of substring what (ignoring case) between from and to positions. |
String:dedent () | Returns a copy of the string with indentation (leading tabs and spaces) removed. |
String:empty () | Returns true if the length of the string equals 0. |
String:ends_with (s) | Returns true if the String ends with the given string. |
String:erase (position, chars) | Erases chars characters from the String starting from position . |
String:find_last (what) | Finds the last occurrence of a substring. |
String:findmk (keys[, from=0]) | Finds the first occurrence of one of the substrings provided in keys . |
String:findn (what[, from=0]) | Finds the first occurrence of a substring, ignoring case. |
String:format (values[, placeholder="{_}"]) | Formats the string by replacing all occurrences of placeholder with values . |
String:get_base_dir () | If the String is a valid file path, returns the base directory name. |
String:get_basename () | If the string is a valid file path, returns the full file path without the extension. |
String:get_extension () | If the string is a valid file path, returns the extension. |
String:get_file () | If the String is a valid file path, returns the filename. |
String:get_slice (splitter, n) | Returns the Nth slice when splitting String with splitter . |
String:get_slice_count (splitter) | Returns the number of slices when splitting String with splitter . |
String:hash () | Hashes the String and returns a 32-bit integer. |
String:hash64 () | Hashes the String and returns a 64-bit integer. |
String:http_escape () | Escapes (encodes) a String to URL friendly format. |
String:http_unescape () | Unescapes (decodes) a String in URL encoded format. |
String:insert (position, what) | Returns a copy of the String with the substring what inserted at the given position. |
String:is_abs_path () | If the String is a path to a file or directory, returns true if the path is absolute. |
String:is_numeric () | Returns whether String contents is a number |
String:is_rel_path () | If the string is a path to a file or directory, returns true if the path is relative. |
String:is_resource_file () | If the string is a path to a file or directory, returns true if the path refers to the Resources folder. |
String:is_subsequence_of (s) | Returns true if this String is a subsequence of the given string. |
String:is_subsequence_ofi (s) | Returns true if this String is a subsequence of the given string, without considering case. |
String:is_valid_float () | Returns true if this String contains a valid float. |
String:is_valid_hex_number ([with_prefix=false]) | Returns true if this String contains a valid hexadecimal number. |
String:is_valid_html_color () | Returns true if this String contains a valid color in hexadecimal HTML notation. |
String:is_valid_identifier () | Returns true if this string is a valid identifier. |
String:is_valid_integer () | Returns true if this String contains a valid integer. |
String:is_valid_ip_address () | Returns true if this String contains only a well-formatted IPv4 or IPv6 address. |
String:json_escape () | Returns a copy of the String with special characters escaped using the JSON standard. |
String:left ([position=0]) | Returns a number of characters from the left of the String. |
String:length () | Returns the String's amount of characters |
String:lpad (min_length[, character=" "]) | Left-pad String with the given character. |
String:md5_buffer () | Returns the MD5 hash of the String as an array of bytes. |
String:md5_text () | Returns the MD5 hash of the String as a String. |
String:naturalnocasecmp_to (s) | Performs a case-insensitive natural order comparison to another string |
String:nocasecmp_to (s) | Performs a case-insensitive comparison to another string. |
String:ord_at () | Returns the character code at position at . |
String:path_to (path) | Returns a String with the relative path from this String to path . |
String:path_to_file (path) | Returns a String with the relative path from this String to path . |
String:percent_decode () | Decode a percent-encoded string. |
String:percent_encode () | Percent-encodes a string. |
String:plus_file (file) | If the String is a path, concatenates file at the end of the String as a subpath. |
String:replace (what, forwhat) | Replaces occurrences of a case-sensitive substring with the given one inside the String. |
String:replace_first (what, forwhat) | Replaces the first occurrence of a case-sensitive substring with the given one inside the String. |
String:replacen (what, forwhat) | Replaces occurrences of a case-insensitive substring with the given one inside the String. |
String:rfind (what[, from=-1]) | Performs a case-sensitive search for a substring, but starts from the end of the String instead of the beginning. |
String:rfindn (what[, from=-1]) | Performs a case-insensitive search for a substring, but starts from the end of the String instead of the beginning. |
String:right ([position=0]) | Returns the right side of the String from a given position. |
String:rpad (min_length[, character=" "]) | Right-pad String with the given character. |
String:rsplit (delimiter[, allow_empty=true[, maxsplit=0]]) | Splits the String by a delimiter String and returns an array of the substrings, starting from right. |
String:rstrip (chars) | Returns a copy of the String with characters removed from the right. |
String:sha256_buffer () | Returns the SHA-256 hash of the String as an array of bytes. |
String:sha256_text () | Returns the SHA-256 hash of the String as a String. |
String:similarity (s) | Returns the similarity index of the text compared to this string. |
String:simplify_path () | Returns a simplified version of the path String. |
String:split (delimiter[, allow_empty=true]) | Splits the String by a delimiter string and returns an array of the substrings. |
String:split_floats (delimiter[, allow_empty=true]) | Splits the String in numbers by using a delimiter and returns an array of reals. |
String:split_floats (delimiter[, allow_empty=true]) | Splits the String in integers by using a delimiter string and returns an array of integers. |
String:split_spaces () | Splits the String by whitespace and returns an array of the substrings. |
String:sprintf (...) | Formats the String by substituting placeholder character-sequences with the given values (reference documentation) |
String:strip_edges ([left=true[, right=true]]) | Returns a copy of the String stripped of any non-printable character (including tabulations, spaces and line breaks) at the beginning and the end. |
String:strip_escapes () | Returns a copy of the String stripped of any escape character. |
String:substr ([from=0[, len=-1]]) | Returns part of the String from the position from with length len. |
String:to_ascii () | Converts the String to a Lua string, assuming all characters are encoded in ASCII. |
String:to_ascii_extended () | Converts the String to a Lua string, assuming all characters are encoded in extended ASCII. |
String:to_lower () | Returns the string converted to lowercase. |
String:to_number ([base]) | Return Lua's tonumber applied to self. |
String:to_upper () | Returns the string converted to uppercase. |
String:to_utf8 () | Converts the String to a Lua string, assuming all characters are encoded in UTF-8. |
String:trim_prefix () | Removes a given String from the start if it starts with it or leaves it unchanged. |
String:trim_suffix () | Removes a given String from the end if it ends with it or leaves it unchanged. |
String:wide_str () | Return the String as a wide char string (const wchar_t * ). |
String:word_wrap (chars_per_line) | Returns a copy of the String with words wrapped at chars_per_line characters. |
String:xml_escape ([escape_quotes=false]) | Returns a copy of the string with special characters escaped using the XML standard. |
String:xml_unescape (self) | Returns a copy of the string with escaped characters replaced by their meanings according to the XML standard. |
Static Functions
String:hex_encode_buffer (buffer[, len=#buffer]) | Encode a sized byte buffer into a String with hexadecimal numbers. |
String:humanize_size (size) | Converts size represented as number of bytes to human-readable format using internationalized set of data size units, namely: B, KiB, MiB, GiB, TiB, PiB, EiB. |
Metamethods
String:__concat (a, b) | Concatenates values. |
String:__eq (a, b) | Equality comparison (a == b ). |
String:__len () | Alias for length |
String:__lt (a, b) | Less than comparison (a < b ). |
String:__mod () | Alias for sprintf, allowing the idiom `String(format) % { ... |
String:__new ([text[, length]]) | String constructor, called by the idiom String(...) |
String:__tostring () | Alias for to_utf8 |
Methods compatible with Lua's string library
String:byte ([i[, j]]) | Wrapper for string.byte |
String:find (pattern[, init[, plain]]) | Wrapper for string.find |
String:gmatch (pattern) | Wrapper for string.gmatch |
String:gsub (pattern, replacement[, n]) | Wrapper for string.gsub |
String:join (...) | Wrapper for string.join . |
String:len () | Wrapper for string.len |
String:lower () | Wrapper for string.lower |
String:match (pattern[, init]) | Wrapper for string.match |
String:rep (n[, sep]) | Wrapper for string.rep |
String:reverse () | Wrapper for string.reverse |
String:sub ([i[, j]]) | Wrapper for string.sub |
String:upper () | Wrapper for string.upper |
Methods
- String:begins_with (s)
-
Returns
true
if the String begins with the given string.Parameters:
- s Other value, stringified with GD.str
Returns:
-
bool
- String:bigrams ()
-
Returns the bigrams (pairs of consecutive letters) of this string.
Returns:
- String:c_escape ()
-
Returns a copy of the string with special characters escaped using the C language standard.
Returns:
- String:c_escape_multiline ()
-
Returns a copy of the string with the special characters
\
and"
escaped using the C language standard.Returns:
- String:c_unescape ()
-
Returns a copy of the string with escaped characters replaced by their meanings.
Supported escape sequences are
\'
,\"
,\?
,\
,\a
,\b
,\f
,\n
,\r
,\t
,\v
.Returns:
- String:camelcase_to_underscore ([lowercased=true])
-
Returns a copy of String with Camel cased words separated by underscores.
If
lowercased
is absent or truthy, result is converted to lower case.Parameters:
- lowercased (default true)
Returns:
- String:capitalize ()
-
Changes the case of some letters.
Replaces underscores with spaces, adds spaces before in-word uppercase characters, converts all letters to lowercase, then capitalizes the first letter and every letter following a space character.
For
capitalize camelCase mixed_with_underscores
, it will returnCapitalize Camel Case Mixed With Underscores
.Returns:
- String:casecmp_to (s)
-
Performs a case-sensitive comparison to another string.
Parameters:
- s Other value, stringified with GD.str
Returns:
-
int
-1 if less than, 1 if greater than, or 0 if equal
- String:count (what[, from=0[, to=0]])
-
Returns the number of occurrences of substring
what
betweenfrom
andto
positions. Iffrom
andto
equals 0 the whole string will be used. If onlyto
equals 0 the remained substring will be used.Parameters:
- what Substring, stringified with GD.str
- from (default 0)
- to (default 0)
Returns:
-
int
- String:countn (what[, from=0[, to=0]])
-
Returns the number of occurrences of substring
what
(ignoring case) betweenfrom
andto
positions. Iffrom
andto
equals 0 the whole string will be used. If onlyto
equals 0 the remained substring will be used.Parameters:
- what Substring, stringified with GD.str
- from (default 0)
- to (default 0)
Returns:
-
int
- String:dedent ()
-
Returns a copy of the string with indentation (leading tabs and spaces) removed.
Returns:
- String:empty ()
-
Returns
true
if the length of the string equals 0.Returns:
-
bool
- String:ends_with (s)
-
Returns
true
if the String ends with the given string.Parameters:
- s Other value, stringified with GD.str
Returns:
-
bool
- String:erase (position, chars)
-
Erases
chars
characters from the String starting fromposition
.Parameters:
- position int
- chars int
- String:find_last (what)
-
Finds the last occurrence of a substring.
Parameters:
- what Substring, stringified with GD.str
Returns:
-
int
Starting position of the substring or -1 if not found
- String:findmk (keys[, from=0])
-
Finds the first occurrence of one of the substrings provided in
keys
.Parameters:
- keys Array Array of substrings
- from (default 0)
Returns:
- int Starting position of the found substring
- int Index of the key found
Or
-
int
-1 if not found
- String:findn (what[, from=0])
-
Finds the first occurrence of a substring, ignoring case.
Parameters:
- what Substring, stringified with GD.str
- from (default 0)
Returns:
-
int
Starting position of the substring or -1 if not found
- String:format (values[, placeholder="{_}"])
-
Formats the string by replacing all occurrences of
placeholder
withvalues
.Parameters:
- values
- placeholder (default "{_}")
Returns:
- String:get_base_dir ()
-
If the String is a valid file path, returns the base directory name.
Returns:
- String:get_basename ()
-
If the string is a valid file path, returns the full file path without the extension.
Returns:
- String:get_extension ()
-
If the string is a valid file path, returns the extension.
Returns:
- String:get_file ()
-
If the String is a valid file path, returns the filename.
Returns:
- String:get_slice (splitter, n)
-
Returns the Nth slice when splitting String with
splitter
.Parameters:
- splitter Splitter substring, stringified with GD.str
- n int Slice index
Returns:
Or
-
Empty string, if there is no Nth slice
- String:get_slice_count (splitter)
-
Returns the number of slices when splitting String with
splitter
.Parameters:
- splitter Splitter substring, stringified with GD.str
Returns:
-
int
Number of slices
- String:hash ()
-
Hashes the String and returns a 32-bit integer.
Returns:
-
int
- String:hash64 ()
-
Hashes the String and returns a 64-bit integer.
Returns:
-
int
- String:http_escape ()
-
Escapes (encodes) a String to URL friendly format.
Also referred to as 'URL encode'.
Returns:
- String:http_unescape ()
-
Unescapes (decodes) a String in URL encoded format.
Also referred to as 'URL decode'.
Returns:
- String:insert (position, what)
-
Returns a copy of the String with the substring
what
inserted at the given position.Parameters:
- position int
- what Value to be inserted, stringified with GD.str
Returns:
- String:is_abs_path ()
-
If the String is a path to a file or directory, returns
true
if the path is absolute.Returns:
-
bool
- String:is_numeric ()
-
Returns whether String contents is a number
Returns:
-
bool
- String:is_rel_path ()
-
If the string is a path to a file or directory, returns
true
if the path is relative.Returns:
-
bool
- String:is_resource_file ()
-
If the string is a path to a file or directory, returns
true
if the path refers to the Resources folder.Returns:
-
bool
- String:is_subsequence_of (s)
-
Returns
true
if this String is a subsequence of the given string.Parameters:
- s Other value, stringified with GD.str
Returns:
-
bool
- String:is_subsequence_ofi (s)
-
Returns
true
if this String is a subsequence of the given string, without considering case.Parameters:
- s Other value, stringified with GD.str
Returns:
-
bool
- String:is_valid_float ()
-
Returns
true
if this String contains a valid float.Returns:
-
bool
- String:is_valid_hex_number ([with_prefix=false])
-
Returns
true
if this String contains a valid hexadecimal number.Parameters:
- with_prefix
If truthy, only matches if the prefix
0x
is present (default false)
Returns:
-
bool
- with_prefix
If truthy, only matches if the prefix
- String:is_valid_html_color ()
-
Returns
true
if this String contains a valid color in hexadecimal HTML notation. Other HTML notations such as named colors orhsl()
colors aren't considered valid by this method and will returnfalse
.Returns:
-
bool
- String:is_valid_identifier ()
-
Returns
true
if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores (_
) and the first character may not be a digit.Returns:
-
bool
- String:is_valid_integer ()
-
Returns
true
if this String contains a valid integer.Returns:
-
bool
- String:is_valid_ip_address ()
-
Returns
true
if this String contains only a well-formatted IPv4 or IPv6 address. This method considers reserved IP addresses such as0.0.0.0
as valid.Returns:
-
bool
- String:json_escape ()
-
Returns a copy of the String with special characters escaped using the JSON standard.
Returns:
- String:left ([position=0])
-
Returns a number of characters from the left of the String.
Parameters:
- position int (default 0)
Returns:
- String:length ()
-
Returns the String's amount of characters
Returns:
-
int
- String:lpad (min_length[, character=" "])
-
Left-pad String with the given character.
Parameters:
- min_length int Desired minimum length
- character Pad character, stringified with GD.str (default " ")
Returns:
- String:md5_buffer ()
-
Returns the MD5 hash of the String as an array of bytes.
Returns:
- String:md5_text ()
-
Returns the MD5 hash of the String as a String.
Returns:
- String:naturalnocasecmp_to (s)
-
Performs a case-insensitive natural order comparison to another string
Parameters:
- s Other value, stringified with GD.str
Returns:
-
int
-1 if less than, 1 if greater than, or 0 if equal
- String:nocasecmp_to (s)
-
Performs a case-insensitive comparison to another string.
Parameters:
- s Other value, stringified with GD.str
Returns:
-
int
-1 if less than, 1 if greater than, or 0 if equal
- String:ord_at ()
-
Returns the character code at position
at
.Returns:
- String:path_to (path)
-
Returns a String with the relative path from this String to
path
.Parameters:
- path Destiny directory path, stringified with GD.str
Returns:
- String:path_to_file (path)
-
Returns a String with the relative path from this String to
path
.Parameters:
- path Destiny file path, stringified with GD.str
Returns:
- String:percent_decode ()
-
Decode a percent-encoded string.
Returns:
See also:
- String:percent_encode ()
-
Percent-encodes a string.
Encodes parameters in a URL when sending a HTTP GET request (and bodies of form-urlencoded POST requests).
Returns:
- String:plus_file (file)
-
If the String is a path, concatenates
file
at the end of the String as a subpath.Parameters:
- file File path to be concatenated, stringified with GD.str
Returns:
- String:replace (what, forwhat)
-
Replaces occurrences of a case-sensitive substring with the given one inside the String.
Parameters:
Returns:
- String:replace_first (what, forwhat)
-
Replaces the first occurrence of a case-sensitive substring with the given one inside the String.
Parameters:
Returns:
- String:replacen (what, forwhat)
-
Replaces occurrences of a case-insensitive substring with the given one inside the String.
Parameters:
Returns:
- String:rfind (what[, from=-1])
-
Performs a case-sensitive search for a substring, but starts from the end of the String instead of the beginning.
Parameters:
- what Substring to be searched, stringified with GD.str
- from int Search start position (default -1)
Returns:
-
int
Position of substring, if it was found
Or
-
int
-1 otherwise
- String:rfindn (what[, from=-1])
-
Performs a case-insensitive search for a substring, but starts from the end of the String instead of the beginning.
Parameters:
- what Substring to be searched, stringified with GD.str
- from int Search start position (default -1)
Returns:
-
int
Position of substring, if it was found
Or
-
int
-1 otherwise
- String:right ([position=0])
-
Returns the right side of the String from a given position.
Parameters:
- position int (default 0)
Returns:
- String:rpad (min_length[, character=" "])
-
Right-pad String with the given character.
Parameters:
- min_length int Desired minimum length
- character Pad character, stringified with GD.str (default " ")
Returns:
- String:rsplit (delimiter[, allow_empty=true[, maxsplit=0]])
-
Splits the String by a
delimiter
String and returns an array of the substrings, starting from right.Parameters:
- delimiter Delimiter, stringified with GD.str
- allow_empty If absent or truthy, inserts empty substrings in the resulting Array (default true)
- maxsplit int Maximum number of splits. The default value of 0 means that all items are split. (default 0)
Returns:
- String:rstrip (chars)
-
Returns a copy of the String with characters removed from the right.
The
chars
argument is a String specifying the set of characters to be removed.Parameters:
- chars Characters to be removed, stringified with GD.str
Returns:
- String:sha256_buffer ()
-
Returns the SHA-256 hash of the String as an array of bytes.
Returns:
- String:sha256_text ()
-
Returns the SHA-256 hash of the String as a String.
Returns:
- String:similarity (s)
-
Returns the similarity index of the text compared to this string.
1 means totally similar and 0 means totally dissimilar.
Parameters:
- s Other value, stringified with GD.str
Returns:
-
float
- String:simplify_path ()
-
Returns a simplified version of the path String.
Returns:
- String:split (delimiter[, allow_empty=true])
-
Splits the String by a
delimiter
string and returns an array of the substrings. Thedelimiter
can be of any length.Parameters:
- delimiter Delimiter substring, stringified with GD.str
- allow_empty If absent or truthy, inserts empty substrings in the resulting Array (default true)
Returns:
- String:split_floats (delimiter[, allow_empty=true])
-
Splits the String in numbers by using a delimiter and returns an array of reals.
Parameters:
- delimiter If an Array is passed, all values are used as delimiters. Otherwise, it is stringified with GD.str
- allow_empty If absent or truthy, inserts a number for empty substrings (default true)
Returns:
- String:split_floats (delimiter[, allow_empty=true])
-
Splits the String in integers by using a delimiter string and returns an array of integers.
Parameters:
- delimiter If an Array is passed, all values are used as delimiters. Otherwise, it is stringified with GD.str
- allow_empty If absent or truthy, inserts a number for empty substrings (default true)
Returns:
- String:split_spaces ()
-
Splits the String by whitespace and returns an array of the substrings.
Returns:
- String:sprintf (...)
-
Formats the String by substituting placeholder character-sequences with the given values
(reference documentation)
Parameters:
- ... If only a table or Array value is passed, each value will correspond to a placeholder
Returns:
-
String
Formatted String
Or
- nil
- String Error message, in case format is not compatible with the given values
- String:strip_edges ([left=true[, right=true]])
-
Returns a copy of the String stripped of any non-printable character (including tabulations, spaces and line breaks) at the beginning and the end.
Parameters:
- left Toggle strip left edge (default true)
- right Toggle strip right edge (default true)
Returns:
- String:strip_escapes ()
-
Returns a copy of the String stripped of any escape character.
These include all non-printable control characters of the first page of the ASCII table (< 32), such as tabulation (
\t
) and newline (\n
and\r
) characters, but not spaces.Returns:
- String:substr ([from=0[, len=-1]])
-
Returns part of the String from the position
from
with length len. Passing -1 to len will return remaining characters from given position.Parameters:
- from int (default 0)
- len int (default -1)
Returns:
- String:to_ascii ()
-
Converts the String to a Lua string, assuming all characters are encoded in ASCII.
Returns:
- String:to_ascii_extended ()
-
Converts the String to a Lua string, assuming all characters are encoded in extended ASCII.
Returns:
- String:to_lower ()
-
Returns the string converted to lowercase.
Returns:
- String:to_number ([base])
-
Return Lua's tonumber applied to self.
Parameters:
- base Number base (optional)
Returns:
-
number or nil
- String:to_upper ()
-
Returns the string converted to uppercase.
Returns:
- String:to_utf8 ()
-
Converts the String to a Lua string, assuming all characters are encoded in UTF-8.
Returns:
- String:trim_prefix ()
-
Removes a given String from the start if it starts with it or leaves it unchanged.
Returns:
- String:trim_suffix ()
-
Removes a given String from the end if it ends with it or leaves it unchanged.
Returns:
- String:wide_str ()
-
Return the String as a wide char string (
const wchar_t *
).Returns:
-
const wchar_t *
- String:word_wrap (chars_per_line)
-
Returns a copy of the String with words wrapped at
chars_per_line
characters.Parameters:
- chars_per_line int
Returns:
- String:xml_escape ([escape_quotes=false])
-
Returns a copy of the string with special characters escaped using the XML standard.
Parameters:
- escape_quotes
If truthy, also escape quote characters
'
and"
(default false)
Returns:
- escape_quotes
If truthy, also escape quote characters
- String:xml_unescape (self)
-
Returns a copy of the string with escaped characters replaced by their meanings according to the XML standard.
Parameters:
- self
Static Functions
These don't receive
self
and should be called directly as Array.static_function(...)
- String:hex_encode_buffer (buffer[, len=#buffer])
-
Encode a sized byte buffer into a String with hexadecimal numbers.
Parameters:
- buffer
Lua string or pointer convertible to
const uint8_t *
- len Buffer length (default #buffer)
Returns:
-
String
String with hexadecimal representation of buffer
- buffer
Lua string or pointer convertible to
- String:humanize_size (size)
-
Converts
size
represented as number of bytes to human-readable format using internationalized set of data size units, namely: B, KiB, MiB, GiB, TiB, PiB, EiB. Note that the next smallest unit is picked automatically to hold at most 1024 units.Parameters:
- size int
Returns:
Metamethods
- String:__concat (a, b)
-
Concatenates values.
Parameters:
Returns:
- String:__eq (a, b)
-
Equality comparison (
a == b
). If eithera
orb
are not String or Lua string, always returnfalse
.Parameters:
- a
- b
Returns:
-
bool
- String:__len ()
-
Alias for length
Returns:
-
int
See also:
- String:__lt (a, b)
-
Less than comparison (
a < b
).Parameters:
- a
- b
Returns:
-
bool
Raises:
If eithera
orb
are not String or Lua string. - String:__mod ()
-
Alias for sprintf, allowing the idiom
String(format) % { ... }
found in GDScriptReturns:
Or
- nil
- String
Raises:
If sprintf returns an errorSee also:
- String:__new ([text[, length]])
-
String constructor, called by the idiom
String(...)
Parameters:
- text
If absent, creates an empty String.
If
text
is not a String, StringName, Lua string,wchar_t *
orchar *
, constructs it based on the value returned bytostring(text)
. (optional) - length If present, new String will have at most length characters. (optional)
Returns:
- text
If absent, creates an empty String.
If
- String:__tostring ()
-
Alias for to_utf8
Returns:
See also:
Methods compatible with Lua's string library
- String:byte ([i[, j]])
-
Wrapper for string.byte
Parameters:
- i (optional)
- j (optional)
Returns:
-
Internal numerical codes of the characters
- String:find (pattern[, init[, plain]])
-
Wrapper for string.find
Parameters:
- pattern
- init (optional)
- plain (optional)
Returns:
- Starting index of found pattern
- Ending index of found pattern
- Captures...
Or
-
nil
If pattern is not found
- String:gmatch (pattern)
-
Wrapper for string.gmatch
Parameters:
- pattern
Returns:
-
function
- String:gsub (pattern, replacement[, n])
-
Wrapper for string.gsub
Parameters:
- pattern
- replacement
- n (optional)
Returns:
- String:join (...)
-
Wrapper for
string.join
.Parameters:
- ...
Returns:
See also:
- String:len ()
-
Wrapper for string.len
Returns:
-
int
- String:lower ()
-
Wrapper for string.lower
Returns:
- String:match (pattern[, init])
-
Wrapper for string.match
Parameters:
- pattern
- init (optional)
Returns:
-
Captures...
- String:rep (n[, sep])
-
Wrapper for string.rep
Parameters:
- n
- sep (optional)
Returns:
- String:reverse ()
-
Wrapper for string.reverse
Returns:
- String:sub ([i[, j]])
-
Wrapper for string.sub
Parameters:
- i (optional)
- j (optional)
Returns:
- String:upper ()
-
Wrapper for string.upper
Returns: