Functions on String

This page provides an extract of frequently used functions using string.

Function Input Types Return Type Description
BOOL(str) String Boolean Converts str to Boolean.
$SET(strs) List of strings List of strings Removes duplicated elements from the strs list
$STRSEP(strs, sep) List of strings, String String Creates a string by joining all the strings of strs using the sep separator.
STRTOKENS(str, seps) String, List of strings String Splits str with all separators of seps.

Example: STRTOKENS("The black cat", " " $+ "ac") returns "The" $+ "bl" $+ "k" $+ "cat".

STRTOKENSRE(str, sep) String, String String Splits str with sep separator (regular expression).
STRSUB(str, beginIndex, endIndex) String, Integer, Integer String Returns a substring of str, which begins at beginIndex and ends at endIndex.
STRLOWER(str) String String Converts str string to lowercase.
STRUPPER(str) String String Converts str string to uppercase.
STRUPPER1ST(str) String String Convert the first character of str to uppercase.
STRINDEX(str, subStr, startIndex) String, String, Integer Integer Returns the index of the subStr substring within the str beginning at the startIndex index.
STRCNT(str) String Integer Returns str length.
STRMATCH(str1, str2) String, String Boolean Returns TRUE if str1 matches str2.
Note: Use * for 0-n characters and # for one character. This method is not case-sensitive.
STRMATCHRE(str, re) String, String Boolean Returns TRUE if str string matches re regular expression.

Example: STRMATCHRE("The black cat", "(.)*k") returns TRUE.

STRSUBSTITUTERE(str1, re, str2) String, String, String String Substitutes re regular expression by str2 within str1. Usage of groups is valid and can be referenced by \n where n is the group index starting at 1.

Example: STRSUBSTITUTERE("The black cat", "black (\w+)", "white \1") returns "The white cat".

STRSEARCHRE(str, re) String, String String Searches regular expression re in str and returns matched groups.

Example: STRSEARCHRE("The black cat", "(\S+a\S+)") returns "black" $+ "cat".

STRF(format[, arg1[, arg2[, arg3[, arg4]]]]) String, additional arguments of arbitrary types String

Returns a formatted string where each $n token is replaced by the nth corresponding arguments after format.

Example: STRF("The $1 cat", "black") returns The black cat.

STRF supports Java Formatter syntax to format integer and real numbers.

Note: The datetime format is not supported by STRF, use TIMETOSTR instead. For more information, see Functions on Time.

A formatter is declared within braces between the $ character and the index digit: ${<formatter>}<digit>

STRF("integer '${%4d}1' - real '${%,.4f}2'", 10, 1.1234E7); //integer '  10' - real '11,234,000.0000'"
Note: The escape character used in string is ". For example, "The description of ""val"" is optional." displays: The description of "val" is optional.

Example

To test if the doc1 name matches the string.

STRMATCH(doc1.name, "TestCard*")