Module: gears.string

Various string manipulation and introspection fuctions.

Static module functions

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


Static module functions

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

Parameters:

Name Type(s) Description
text string Text to escape.

Returns:

    string Escaped text.
🔗 gears.string.xml_unescape (text) -> string
Unescape a string from entities.

Parameters:

Name Type(s) Description
text string Text to unescape.

Returns:

    string Unescaped text.
🔗 gears.string.linecount (text) -> int
Count number of lines in a string.

Parameters:

Name Type(s) Description
text string Input string.

Returns:

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

Parameters:

Name Type(s) Description
text string String to wrap.
width number Maximum length of each line. Default: 72.
indent number Number of spaces added before each wrapped line. Default: 0.

Returns:

    string The string with lines wrapped to width.
🔗 gears.string.quote_pattern (s) -> string
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

Parameters:

Name Type(s) Description
s string String to generate pattern for

Returns:

    string string with escaped characters
🔗 gears.string.query_to_pattern (q) -> string
Generate a pattern matching expression that ignores case.

Parameters:

Name Type(s) Description
q string Original pattern matching expression.

Returns:

    string The pattern.
🔗 gears.string.split (str, delimiter) -> table
Split separates a string containing a delimiter into the list of substrings between that delimiter.

Parameters:

Name Type(s) Description
str string String to be splitted
delimiter string Character where the string will be splitted

Returns:

    table list of the substrings
🔗 gears.string.split (str, pattern) -> table
Pattern split separates a string by a pattern to the table of substrings.

Parameters:

Name Type(s) Description
str string String to be splitted
pattern string[opt="\n"] Pattern the target string will be splitted by.

Returns:

    table A list of substrings.
🔗 gears.string.startswith (str, sub) -> boolean
Check if a string starts with another string.

Parameters:

Name Type(s) Description
str string String to search
sub string String to check for.

Returns:

    boolean true if string starts with specified string
🔗 gears.string.endswith (str, sub) -> boolean
Check if a string ends with another string.

Parameters:

Name Type(s) Description
str string String to search
sub string String to check for.

Returns:

    boolean true if string ends with specified string
generated by LDoc 1.5.0 based on AwesomeWM template