Module jls.util.strings

Provide string helper functions.

Functions

strings.split (value, pattern, plain) Returns a list of strings split at each pattern.
strings.parts (value, pattern[, plain]) Returns an iterator function and the string value.
strings.cut (size, value) Returns a list of strings cut with the same size.
strings.equalsIgnoreCase (a, b) Returns true if the specified strings are equals case insensitive or both nil.
strings.hash (value) Returns an integer for the specified string.
strings.encodeVariableByteInteger (i) Returns the string representing the specified integer The most significant bit is set to 1 to indicate that another byte is used.
strings.decodeVariableByteInteger (s[, offset]) Returns the integer represented by the specified string
strings.formatInteger (value[, radix[, len[, chars[, pad]]]]) Returns a string representing the specified integer in the specified radix.
strings.escape (value) Returns the pattern corresponding to the specified string with the magic characters ^$()%.[]*+-?


Functions

strings.split (value, pattern, plain)
Returns a list of strings split at each pattern.

Parameters:

  • value string The string to split.
  • pattern string The pattern used to split the string.
  • plain boolean true to find the pattern as a plain string.

Returns:

    table a list of strings split at each pattern.
strings.parts (value, pattern[, plain])
Returns an iterator function and the string value. When used in a for loop it will iterate over all values. If the pattern is a number it will be used to cut the string in values of the same size.

Parameters:

  • value string The string to split.
  • pattern The pattern used to split the string.
  • plain boolean true to find the pattern as a plain string. (optional)

Returns:

  1. function an iterator function
  2. string value The string to split
strings.cut (size, value)
Returns a list of strings cut with the same size.

Parameters:

  • size number The size to cut.
  • value string The string to split.

Returns:

    table a list of strings cut at each pattern.
strings.equalsIgnoreCase (a, b)
Returns true if the specified strings are equals case insensitive or both nil.

Parameters:

Returns:

    boolean true if the specified strings are equals.
strings.hash (value)
Returns an integer for the specified string. If two strings are equals then each string produce the same integer. The result integer uses all the integer possible values from math.mininteger to math.maxinteger. The result integer for a specific string may change in futur versions.

Parameters:

  • value string The string to hash.

Returns:

    integer a hash integer value.
strings.encodeVariableByteInteger (i)
Returns the string representing the specified integer The most significant bit is set to 1 to indicate that another byte is used.

Parameters:

  • i number the integer to encode

Returns:

    string the encoded value as a string.
strings.decodeVariableByteInteger (s[, offset])
Returns the integer represented by the specified string

Parameters:

  • s string the encoded integer
  • offset number the starting offset, default is 1 (optional)

Returns:

  1. number the decoded integer or nil.
  2. number the end offset
strings.formatInteger (value[, radix[, len[, chars[, pad]]]])
Returns a string representing the specified integer in the specified radix.

Parameters:

  • value integer The integer to format.
  • radix integer The radix to use from 2 to 64, default is 10. (optional)
  • len integer The minimal length of the resulting string padded with zero. (optional)
  • chars string A string containing the characters used to format. (optional)
  • pad string The character used to pad. (optional)

Returns:

    string a string representing the integer.
strings.escape (value)
Returns the pattern corresponding to the specified string with the magic characters ^$()%.[]*+-? escaped.

Parameters:

  • value string The string to escape.

Returns:

    string The corresponding pattern.
generated by LDoc 1.4.6