String - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki
An addon to Lua's standard string library.
This addon can be declared with the name "string" since it does NOT override the Lua's standard string library. Additionally, methods in this addon can be treated with the OOP (Object-oriented Programming) syntax when used on strings.
local string = require 'ghostutil.lua-addons.string'split(*s: string, ?delimiter: string): table<string>Splits the passed string into a string table of substrings based on the given delimiter.
Parameters:
-
s(ignored on OOP): The string to split. -
delimiter(optional): The seperator.
Returns: Table containing the substrings, the delimeter is not included in the string itself.
─────────────────────────
shuffle(*s: string): stringShuffles the passed string.
Parameters:
-
s(ignored on OOP): The string to shuffle.
Returns: The shuffled string.
─────────────────────────
ltrim(*s: string): stringRemoves the trailing spaces on the string's left end
Parameters:
-
s: (ignored on OOP): The string to trim.
Returns: The trimmed string.
─────────────────────────
rtrim(*s: string): stringRemoves the trailing spaces on the string's right end.
Parameters:
-
s: (ignored on OOP): The string to trim.
Returns: The trimmed string.
─────────────────────────
trim(*s: string): stringRemoves trailing spaces on a string from both ends.
(Shortcut for string.ltrim(string.rtrim(s)))
Parameters:
-
s: (ignored on OOP): The string to trim.
Returns: The trimmed string.
─────────────────────────
startswith(*s: string, startsWith: string): booleanChecks if the passed string starts with the given string.
Parameters:
-
s: (ignored on OOP): The string to check. -
startsWith: The starting string that the function should check.
Returns: true if s starts with startsWith.
─────────────────────────
endswith(*s: string, endsWith: string): booleanChecks if the passed string ends with the given string.
Parameters:
-
s: (ignored on OOP): The string to check. -
endsWith: The ending string that the function should check.
Returns: true if s ends with endsWith.
─────────────────────────
contains(*s: string, pattern: string): stringChecks if the passed string contains the given pattern.
Parameters:
-
s: (ignored on OOP): The string to check. -
pattern: The pattern it should check for.
Returns: true if pattern is found inside s.
─────────────────────────
replace(*s: string, pattern: string, to: string): stringReplaces pattern found in s to to.
(Shortcut for s:gsub(pattern, to))
Parameters:
-
s: (ignored on OOP): The string to compute. -
pattern: The pattern to be replaced. -
to: The value to replacepatternwith.
Returns: The string after pattern is replaced with to.
GhostUtil 3.0.0 • Docs 3.0.0, Revision 1
a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDev — Ghost's Utilities
Licensed under the MIT License.