StringUtil
The StringUtil module provides utility functions for Lua strings.
Trim(String str)
¶
Trims whitespace from the start and end of the string.
1 |
|
TrimStart(String str)
¶
The same as Trim, but only trims the start of the string.
1 |
|
TrimEnd(String str)
¶
The same as Trim, but only trims the end of the string.
1 |
|
EqualsIgnoreCase(String str, String compare)
¶
Checks if two strings are equal, but ignores their case.
1 |
|
RemoveWhitespace(String str)
¶
Removes all whitespace from a string.
1 |
|
RemoveExcessWhitespace(String str)
¶
Replaces all whitespace with a single space. This does not trim the string.
1 |
|
EndsWith(String str, String endsWith)
¶
Checks if a string ends with a certain string.
1 |
|
StartsWith(String str, String startsWith)
¶
Checks if a string starts with a certain string.
1 |
|
Contains(String str, String contains)
¶
Checks if a string contains another string.
1 |
|
ToCharArray(String str)
¶
Returns a table of all the characters in the string.
1 |
|
ToByteArray(String str)
¶
Returns a table of all the bytes of each character in the string.
1 |
|
ByteArrayToString(Table bytes)
¶
Transforms an array of bytes into a string.
1 |
|
ToCamelCase(String str)
¶
Returns a string in camelCase.
1 |
|
ToPascalCase(String str)
¶
Returns a string in PascalCase.
1 |
|
ToSnakeCase(String str [, uppercase])
¶
Returns a string in snake_case or SNAKE_CASE.
1 2 |
|
ToKebabCase(String str [, uppercase])
¶
Returns a string in kebab-case or KEBAB-CASE.
1 2 |
|
Escape(str)
¶
Escapes a string from pattern characters. In other words, it prefixes any special pattern characters with a %. For example, the dollar sign $ would become %$. See the example below.
1 |
|
StringBuilder()
¶
Creates a StringBuilder object that can be used to build a string. This is useful when a large string needs to be concatenated. Traditional concatenation of a string using ".." can be a performance issue, and thus StringBuilders can be used to store the pieces of the string in a table and then concatenate them all at once.
1 2 3 4 5 6 |
|