User Tools

Site Tools


addons:using_libs:stringex

Stringex Library

The stringex library exposes more functions to the built-in Lua string library.

The following functions are exposed by this library:

boolean string.contains(s, p);

  • Parameters
    • s - The string to search within.
    • p - The string to look for.
  • Returns
    • True if found, false otherwise.

boolean string.startswith(s, s2);

  • Parameters
    • s - The string to search within.
    • s2 - The string to look for.
  • Returns
    • True if found, false otherwise.

boolean string.endswith(s, s2);

  • Parameters
    • s - The string to search within.
    • s2 - The string to look for.
  • Returns
    • True if found, false otherwise.

string string.upperfirst(s);

  • Parameters
    • s - The string to upper-case the first letter of.
  • Returns
    • The new formatted string.

string string.topropercase(s);

  • Parameters
    • s - The string to proper case.
  • Returns
    • The new formatted string.

string string.insert(s, p, s2);

  • Parameters
    • s - The string to insert into.
    • p - The position to insert the new string.
    • s2 - The new string to insert.
  • Returns
    • The new string.

string string.remove(s, index);

  • Parameters
    • s - The string to remove from.
    • index - The starting spot to begin removing characters.
  • Returns
    • The new string.

string string.lpad(s, s2, n);

  • Parameters
    • s - The string to pad.
    • s2 - The padding string to insert into the new string.
    • n - The space to pad.
  • Returns
    • The new string.

string string.rpad(s, s2, n);

  • Parameters
    • s - The string to pad.
    • s2 - The padding string to insert into the new string.
    • n - The space to pad.
  • Returns
    • The new string.

string string.hex(s, sep);

  • Parameters
    • s - The string to convert to hex.
    • sep - The separator to use between each hex value. (Default is space.)
  • Returns
    • The hex string.

string string.fromhex(s);

  • Parameters
    • s - The hex string to convert to a normal string.
  • Returns
    • The new string.

table string.totable(s);

  • Parameters
    • s - The string to convert to a table.
  • Returns
    • A table containing the characters of the given string.

string string.clean(s, trimend);

  • Parameters
    • s - The string to trim.
    • trimend - Boolean to tell if we should trim the end of the string or not.
  • Returns
    • The trimmed string.

string string.trimstart(s, char);

  • Parameters
    • s - The string to trim.
    • char - The character to trim from the string. (Default is space.)
  • Returns
    • The trimmed string.

string string.trimend(s, char);

  • Parameters
    • s - The string to trim.
    • char - The character to trim from the string. (Default is space.)
  • Returns
    • The trimmed string.

string string.trim(s, char);

  • Parameters
    • s - The string to trim.
    • char - The character to trim from the string. (Default is space.)
  • Returns
    • The trimmed string.

table string:GetArgs()

  • Parameters
    • Function has no additional arguments.
  • Returns
    • A table containing the arguments from the calling string.

string string:IsQuotedArg()

  • Parameters
    • Function has no additional arguments.
  • Returns
    • (1) True or false if the argument is quoted.
    • (2) The argument if found.

table string:ParseArgs()

  • Parameters
    • Function has no additional arguments.
  • Returns
    • A table containing the arguments from the calling string.
addons/using_libs/stringex.txt · Last modified: 2015/11/19 23:35 by atom0s