String - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki

lua-addons/string.lua

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'

Methods

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): string

Shuffles the passed string.

Parameters:

  • s (ignored on OOP): The string to shuffle.

Returns: The shuffled string.

─────────────────────────

ltrim(*s: string): string

Removes 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): string

Removes 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): string

Removes 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): boolean

Checks 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): boolean

Checks 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): string

Checks 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): string

Replaces 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 replace pattern with.

Returns: The string after pattern is replaced with to.



GhostUtil 3.0.0Docs 3.0.0, Revision 1

a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDevGhost's Utilities
Licensed under the MIT License.

⚠️ **GitHub.com Fallback** ⚠️