Skip to content

library__str

Robert Bossy edited this page Jul 27, 2017 · 1 revision

#str

Synopsis

Functions to manipulate character strings.

Functons

str:before(target, sub)

Evaluates target and sub as strings, then returns the substring of target before the first occurrence of sub. If sub cannot be found, then this function returns target.

str:after:sub(target)

Evaluates target as a string, then returns the substring of target after the first occurrence of sub. If sub cannot be found, then this function returns target.

str:basename(path)

Treats path as a file path and returns the last element of path.

str:after(target, sub)

Evaluates target and sub as strings, then returns the substring of target after the first occurrence of sub. If sub cannot be found, then this function returns target.

str:before:sub(target)

Evaluates target as a string, then returns the substring of target before the first occurrence of sub. If sub cannot be found, then this function returns target.

str:cmp(a, b)

Evaluates a and b as strings, then compares the results. This function returns -1, 0 or 1 when a is lower, equal or greater than b.

str:diacritics(s)

Evaluates s as a string, then returns the result with diacritics removed.

str:equalsIgnoreCase(a, b)

Evaluates a and b as strings, then returns either the two strings are equal ignoring the character case.

str:hash(s)

Returns a hash code computed from s.

str:index(s, target)

Evaluates s and target as strings, then returns the number of characters in s before the first occurrence of target in s. If there is no occurrence of target in s, then this function returns -1.

str:join(items, string, separator)

Evaluates items as a list of elements and separator as a string. Then for each element of items, this function evaluates string as a string and returns a concatenation of the results seperated with separator

str:join:separator(items, string)

Evaluates items as a list of elements, then for each element of items, this function evaluates string as a string and returns a concatenation of the results seperated with separator

str:join(items, string)

Evaluates items as a list of elements, then for each element of items, this function evaluates string as a string and returns a concatenation of the results seperated with a single whitespace.

str:len(target)

Evaluates target as a string, then returns the number of characters in the result.

str:levenshtein(a, b)

Evaluates a and b as strings, then returns the edit distance between the results.

str:levenshteinSimilar(a, b, d)

Evaluates a and b as strings and d as a float, then returns either the edit distance between a and b is lower or equal than d. This function is useful for approximate string matching.

str:lower(target)

Evaluates target as a string and returns it with all characters converted to lower case.

str:normalizeSpace(s)

Evaluates s as a string, then returns the result with leading and trailing whitespace characters removed, and sequences of whitespaces characters replaced with a single space character.

str:padl(s, n)

Forces s to length n. If shorter, then this function adds as many spaces necessary at the beginning. If longer, then this function truncates s.

str:padl:filler(s, n)

Forces s to length n. If shorter, then this function adds as many filler necessary at the beginning. If longer, then this function truncates s.

str:padr(s, n)

Forces s to length n. If shorter, then this function adds as many spaces necessary at the end. If longer, then this function truncates s.

str:padr:filler(s, n)

Forces s to length n. If shorter, then this function adds as many filler necessary at the end. If longer, then this function truncates s.

str:regrp(s, re, n)

Compiles re as a regular expression and searches in s. This function returns the n capturing group of the regular expression.

str:replace(target, search, replace)

Evaluates target, search and replace as strings, then returns target with all non-overlapping occurrences of search substituted with replace.

str:rindex(s, target)

Evaluates s and target as strings, then returns the number of characters in s after the last occurrence of target in s. If there is no occurrence of target in s, then this function returns -1.

str:seds(target, pattern, replace)

Evaluates target, pattern and replace as strings, then interprets pattern as a Java Regular Expression. This function returns target with all non-overlapping matches of pattern substituted with replace.

str:split:separator:feature(target)

Evaluate target as a string, then splits it by the first character of separator. The adds each string into the context feature named feature. Feature modification must be allowed.

str:sub(target, from, to)

Evaluates target as a string, from and to as integers, then returns the subsequence of target between indexes from (inclusive) and to (exclusive). Indexes start at 0.

str:sub(target, from)

Evaluates target as a string and from as an integer, then returns the subsequence of target from index from (inclusive) and to (exclusive)to its end. Indexes start at 0.

str:trim(s)

Evaluates s as a string, then returns the result with leading and trailing whitespace characters removed.

str:upper(target)

Evaluates target as a string and returns it with all characters converted to upper case.

Clone this wiki locally