string¶
The String library provides a set of functions for working with strings in Lua. These functions can be used to manipulate and transform strings, search for patterns in strings, and format strings for output.
Functions¶
string format(... arguments)¶
ReturnsThe result string.
Function is used to format strings based on a specified format string and any additional values that need to be included in the resulting string. The function takes a format string as its first argument, which defines the structure and contents of the resulting string, and one or more additional arguments that are used to populate the format string.
arguments
The arguments.
string rep(number n)¶
ReturnsThe result.
Function returns a new string that consists of n copies of the input string s. The function takes two arguments: the input string s, and an integer n that specifies how many copies of s to include in the resulting string.
n
The count.
string reverse()¶
ReturnsThe new string.
Function that takes a string as an argument and returns a new string with the characters in reverse order.
string sub(number i, number j)¶
ReturnsThe new string.
Function that returns a substring of string s that starts at index i and ends at index j (or the end of the string if j is not specified). If i is negative, the starting index is considered to be the end of the string minus the absolute value of i plus 1. If j is negative, the ending index is considered to be the end of the string minus the absolute value of j. If j is not specified, the function returns the substring starting from index i to the end of the string. If both i and j are not specified, the function returns the entire string.
i
The start index.j
The end index.
string lower()¶
ReturnsThe new string.
Function that used to convert a given string to lowercase. It takes a single parameter, a string, and returns a new string with all uppercase characters converted to lowercase.
string upper()¶
ReturnsThe new string.
Function returns a new string with all the characters in the given string converted to uppercase.
number len()¶
ReturnsThe length.
Function that used to get the length of a string. It takes a single parameter, a string, and returns the length of the string as an integer. The length of the string is the number of characters in the string.