Module stringutil
Various utility functions for working with strings.
Functions
concat (...) | Concats all the given items by invoking tostring on them into one string. |
endswith (text, value) | Tests if the given text ends with the given value. |
hash (value) | Creates a simple hash in the range of mathutil.SIGNED_32BIT_MIN and mathutil.SIGNED_32BIT_MAX (which is roughly -2 billion to 2 billion). |
split (text, split, trim_values) | Splits the given text using the given split value. |
startswith (text, value) | Tests if the given text starts with the given value. |
trim (text) | Trims the given text from any leading and trailing whitespace. |
Functions
- concat (...)
-
Concats all the given items by invoking tostring on them into one string.
Parameters:
- ... The items to concat.
Returns:
-
The concatenated items as string.
- endswith (text, value)
-
Tests if the given text ends with the given value.
Parameters:
- text The text to check if it ends with the given value.
- value The value that text should end with.
Returns:
-
true if the given text ends with the value.
- hash (value)
-
Creates a simple hash in the range of mathutil.SIGNED_32BIT_MIN and
mathutil.SIGNED_32BIT_MAX (which is roughly -2 billion to 2 billion).
Note that this is not the best string hash function there could be, but is
more than sufficient if all you want is to test a string if it is different
or if you want to create a number from a string of unknown length.
Parameters:
- value The string value to hash.
Returns:
-
The hash. Always 0 if the given string is nil or empty.
- split (text, split, trim_values)
-
Splits the given text using the given split value. Returns the splitted text
as List. If the string is empty or nil, the returned list will not contain
any entries. If the string only contains a value without a separator,
the list will contain one value, if it contains only the separator,
two empty values.
Parameters:
- text The text to split.
- split The split value.
- trim_values Optional. If the values should be trimmed, defaults to true.
Returns:
-
The list of splitted values.
- startswith (text, value)
-
Tests if the given text starts with the given value.
Parameters:
- text The text to check if it starts with the given value.
- value The value that text should start with.
Returns:
-
true if the given text starts with the value.
- trim (text)
-
Trims the given text from any leading and trailing whitespace.
Parameters:
- text The text to trim.
Returns:
-
The trimmed text.