Module StdLib.String

Extends Lua 5.2 string.

Functions

trim (s) Returns a copy of the string with any leading or trailing whitespace from the string removed.
starts_with (s, start) Tests if a string starts with a given substring.
ends_with (s, ends) Tests if a string ends with a given substring.
contains (s, contains) Tests if a string contains a given substring.
is_empty (s) Tests whether a string is empty.
split (s[, sep="."[, pattern=false]]) Splits a string into an array.


Functions

trim (s)
Returns a copy of the string with any leading or trailing whitespace from the string removed.

Parameters:

  • s string the string to remove leading or trailing whitespace from

Returns:

    string a copy of the string without leading or trailing whitespace
starts_with (s, start)
Tests if a string starts with a given substring.

Parameters:

  • s string the string to check for the start substring
  • start string the substring to test for

Returns:

    boolean true if the start substring was found in the string
ends_with (s, ends)
Tests if a string ends with a given substring.

Parameters:

  • s string the string to check for the end substring
  • ends string the substring to test for

Returns:

    boolean true if the end substring was found in the string
contains (s, contains)
Tests if a string contains a given substring.

Parameters:

  • s string the string to check for the substring
  • contains string the substring to test for

Returns:

    boolean true if the substring was found in the string
is_empty (s)
Tests whether a string is empty.

Parameters:

Returns:

    boolean true if the string is empty
split (s[, sep="."[, pattern=false]])
Splits a string into an array. *Note:* Empty split substrings are not included in the resulting table.

For example, `string.split("foo.bar...", ".", false)` results in the table `{"foo", "bar"}`.

Parameters:

  • s string the string to split
  • sep string the separator to use. (default ".")
  • pattern boolean whether to interpret the separator as a lua pattern or plaintext for the string split (default false)

Returns:

    {string,...} an array of strings
generated by LDoc 1.4.6 Last updated 2018-06-07 12:58:23