Module: gears.string

String module for gears

Static module functions

gears.string.xml_escape (text) Escape a string from XML char.
gears.string.xml_unescape (text) Unescape a string from entities.
gears.string.linecount (text) Count number of lines in a string
gears.string.linewrap (text, width, indent) Split a string into multiple lines.
gears.string.quote_pattern () Escape all special pattern-matching characters so that lua interprets them literally instead of as a character class.
gears.string.query_to_pattern (s) Generate a pattern matching expression that ignores case.
gears.string.split (str, delimiter) Split separates a string containing a delimiter into the list of substrings between that delimiter.
gears.string.startswith (str, sub) Check if a string starts with another string.
gears.string.endswith (str, sub) Check if a string ends with another string.


Static module functions

gears.string.xml_escape (text)
Escape a string from XML char. Useful to set raw text in textbox.

Parameters:

  • text Text to escape.

Returns:

    Escape text.
gears.string.xml_unescape (text)
Unescape a string from entities.

Parameters:

  • text Text to unescape.

Returns:

    Unescaped text.
gears.string.linecount (text)
Count number of lines in a string

Parameters:

Returns:

    int Number of lines.
gears.string.linewrap (text, width, indent)
Split a string into multiple lines.

Parameters:

  • text String to wrap.
  • width Maximum length of each line. Default: 72.
  • indent Number of spaces added before each wrapped line. Default: 0.

Returns:

    The string with lines wrapped to width.
gears.string.quote_pattern ()
Escape all special pattern-matching characters so that lua interprets them literally instead of as a character class. Source: http://stackoverflow.com/a/20778724/15690
gears.string.query_to_pattern (s)
Generate a pattern matching expression that ignores case.

Parameters:

  • s Original pattern matching expression.
gears.string.split (str, delimiter)
Split separates a string containing a delimiter into the list of substrings between that delimiter.

Parameters:

  • str string String to be splitted
  • delimiter string Character where the string will be splitted

Returns:

    table list of the substrings
gears.string.startswith (str, sub)
Check if a string starts with another string.

Parameters:

  • str string String to search
  • sub string String to check for.
gears.string.endswith (str, sub)
Check if a string ends with another string.

Parameters:

  • str string String to search
  • sub string String to check for.
generated by LDoc 1.4.6 Last updated 2030-01-01 00:00:00