Some functions work with strings.
In the functions that work with strings, sometimes a format pattern of a date or any number must be defined.
For detailed information about date formatting and/or parsing see Data and Time Format.
For detailed information about formatting and/or parsing of any numeric data type see Numeric Format.
For detailed information about locale see Locale.
Note | |
---|---|
Remember that numeric and date formats are displayed using system
value Locale or Locale specified in the For more information on how Locale may be changed in the |
Here we provide the list of the functions:
string charAt(
string arg, integer index)
;
The charAt(string, integer)
function
accepts two arguments: the first is string and the second is integer.
It takes the string and returns the character
that is located at the position specified by the
index
.
string chop(
string arg)
;
The chop(string)
function accepts one
string argument. The function takes this argument, removes the
line feed and the carriage return characters from the end of the
string specified as the argument and returns the new string
without these characters.
string chop(
string arg1, string arg2)
;
The chop(string, string)
function accepts
two string arguments. It takes the first argument, removes the
string specified as the second argument from the end of the first
argument and returns the first string argument without the string
specified as the second argument.
string concat(
string arg1, string ..., string argN)
;
The concat(string, ..., string)
function accepts unlimited number of arguments of string data type.
It takes these arguments and
returns their concatenation.
You can also concatenate these arguments
using plus signs, but this function is faster for more than two
arguments.
integer countChar(
string arg, string character)
;
The countChar(string, string)
function
accepts two arguments: the first is string and the second is one
character. It takes them and returns the number of occurrences of
the character specified as the second argument in the string
specified as the first argument.
string[] cut(
string arg, integer[] indeces)
;
The cut(string, integer[])
function accepts
two arguments: the first is string and the second is list of
integers. The function returns a list of strings. The number of
elements of the list specified as the second argument must be
even.
The integers in the list
serve as position (each number in the odd
position) and length (each number in the even position).
Substrings of the specified length are taken from the string
specified as the first argument starting from the specified
position (excluding the character at the specified position). The
resulting substrings are returned as list of strings. For example,
cut("somestringasanexample",[2,3,1,5])
returns
["mes","omest"]
.
integer editDistance(
string arg1, string arg2)
;
The editDistance(string, string)
function accepts two string arguments. These strings will be
compared to each other. The strength of comparison is 4 by
default, the default value of locale for comparison is the system
value and the maximum difference is 3 by default.
The function returns the number of letters that should be
changed to transform one of the two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
integer editDistance(
string arg1, string arg2, string locale)
;
The editDistance(string, string, string)
function accepts three arguments. The first two are strings that
will be compared to each other and the third (string) is the
locale that will be used for comparison. The default strength of
comparison is 4. The maximum difference is 3 by default.
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
See http://java.sun.com/j2se/1.6.0/docs/api/java/util/Locale.html for details about Locale.
integer editDistance(
string arg1, string arg2, integer strength)
;
The editDistance(string, string, integer)
function accepts three arguments. The first two are strings that
will be compared to each other and the third (integer) is the
strength of comparison. The default locale that will be used for
comparison is the system value. The maximum difference is 3 by
default.
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
integer editDistance(
string arg1, string arg2, integer strength, string locale)
;
The editDistance(string, string, integer,
string)
function accepts four arguments. The first two
are strings that will be compared to each other, the third
(integer) is the strength of comparison and the fourth (string) is
the locale that will be used for comparison. The maximum
difference is 3 by default.
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
See http://java.sun.com/j2se/1.6.0/docs/api/java/util/Locale.html for details about Locale.
integer editDistance(
string arg1, string arg2, string locale, integer maxDifference)
;
The editDistance(string, string, string,
integer)
function accepts four arguments. The first two are
strings that will be compared to each other, the third (string) is
the locale that will be used for comparison and the fourth
(integer) is the maximum difference. The strength of comparison is
4 by default.
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
See http://java.sun.com/j2se/1.6.0/docs/api/java/util/Locale.html for details about Locale.
integer editDistance(
string arg1, string arg2, integer strength, integer maxDifference)
;
The editDistance(string, string, integer,
integer)
function accepts four arguments. The first two are
strings that will be compared to each other and the two others are
both integers. These are the strength of comparison (third
argument) and the maximum difference (fourth argument). The locale
is the default system value.
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
For more details, see another version of the
editDistance()
function below - the
editDistance (string, string, integer, string, integer)
function.
integer editDistance(
string arg1, string arg2, integer strength, string locale, integer maxDifference)
;
The editDistance(string, string, integer, string,
integer)
function accepts five arguments. The first two are
strings, the three others are integer, string and integer,
respectively. The function takes the first two arguments and
compares them to each other using the other three
arguments.
The third argument (integer number) specifies the strength of comparison. It can have any value from 1 to 4.
If it is 4 (identical comparison), that means that only
identical letters are considered equal. In case of 3 (tertiary
comparison), that means that upper and lower cases are considered
equal. If it is 2 (secondary comparison), that means that letters
with diacritical marks are considered equal. Last, if the strength
of comparison is 1 (primary comparison), that means that even the
letters with some specific signs are considered equal. In other
versions of the editDistance()
function where
this strength of comparison is not specified, the number 4 is used
as the default strength (see above).
The fourth argument is the string data type. It is the locale
that serves for comparison. If no locale is specified in other
versions of the editDistance()
function, its
default value is the system value (see above).
The fifth argument (integer number) means the number of
letters that should be changed to transform one of the first two
arguments to the other. If another version of the
editDistance()
function does not specify this
maximum difference, the default maximum difference
is number 3 (see above).
The function returns the number of letters that should be
changed to transform one of the first two arguments to the other.
However, when the function is being executed, if it counts that
the number of letters that should be changed is at least the
number specified as the maximum difference, the execution
terminates and the function returns maxDifference +
1
as the return value.
Actually the function is implemented for the following locales: CA, CZ, ES, DA, DE, ET, FI, FR, HR, HU, IS, IT, LT, LV, NL, NO, PL, PT, RO, SK, SL, SQ, SV, TR. These locales have one thing in common: they all contain language-specific characters. A complete list of these characters can be examined in CTL2 Appendix - List of National-specific Characters
See http://java.sun.com/j2se/1.6.0/docs/api/java/util/Locale.html for details about Locale.
string escapeUrl(
string arg)
;
The function escapes illegal characters within components
of specified URL (see isUrl() CTL2 function
for the URL component description).
Illegal characters must be escaped by
a percent character %
symbol, followed by the two-digit hexadecimal
representation (case-insensitive) of the ISO-Latin code point for
the character, e.g., %20
is the escaped encoding
for the US-ASCII space character.
string[] find(
string arg, string regex)
;
The find(string, string)
function accepts
two string arguments. The second one is regular expression. The
function takes them and returns a list of substrings corresponding
to the regex pattern that are found in the string specified as the
first argument.
string
getAlphanumericChars(
string arg)
;
The getAlphanumericChars(string)
function takes one string argument and returns only letters and
digits contained in the string argument in the order of their
appearance in the string. The other characters are removed.
string
getAlphanumericChars(
string arg, boolean takeAlpha, boolean
takeNumeric)
;
The getAlphanumericChars(string, boolean,
boolean)
function accepts three arguments: one string
and two booleans. It takes them and returns letters and/or digits
if the second and/or the third arguments, respectively, are set to
true.
string
getFieldLabel(
reference record, string arg)
;
The function returns a label of a field whose name is specified
in arg
. The fields are taken from
record
.
string
getFieldLabel(
reference record, integer arg)
;
The function returns a label of a field whose index is specified
in arg
. The fields are taken from
record
.
string
getUrlHost(
string arg)
;
The function parses out host name from specified URL
(see isUrl() CTL2 function
for the scheme). If the hostname part is not present in the URL argument,
an empty string is returned. If the URL is not valid, null
is returned.
string
getUrlPath(
string arg)
;
The function parses out path from specified URL
(see isUrl() CTL2 function
for the scheme). If the path part is not present in the URL argument,
an empty string is returned. If the URL is not valid, null
is returned.
integer
getUrlPort(
string arg)
;
The function parses out port number from specified URL (see isUrl() CTL2 function for the scheme). If the port part is not present in the URL argument, -1 is returned. If the URL has invalid syntax, -2 is returned.
string
getUrlProtocol(
string arg)
;
The function parses out protocol name from specified URL
(see isUrl() CTL2 function
for the scheme). If the protocol part is not present in the URL argument,
an empty string is returned. If the URL is not valid, null
is returned.
string
getUrlQuery(
string arg)
;
The function parses out query (parameters) from specified URL
(see isUrl() CTL2 function
for the scheme). If the query part is not present in the URL argument,
an empty string is returned. If the URL syntax is invalid, null
is returned.
string
getUrlUserInfo(
string arg)
;
The function parses out username and password from specified URL
(see isUrl() CTL2 function
for the scheme). If the userinfo part is not present in the URL argument,
an empty string is returned. If the URL syntax is invalid, null
is returned.
string
getUrlRef(
string arg)
;
The function parses out fragment after # character, also known
as ref, reference or anchor, from specified URL
(see isUrl() CTL2 function for the scheme).
If the fragment part is not present in the URL argument,
an empty string is returned. If the URL syntax is invalid, null
is returned.
integer indexOf(
string arg, string substring)
;
The indexOf(string, string)
function
accepts two strings. It takes them and returns the index of the
first appearance of substring
in the string
specified as the first argument.
integer indexOf(
string arg, string substring, integer fromIndex)
;
The indexOf(string, string, integer)
function accepts three arguments: two strings and one integer. It
takes them and returns the index of the first appearance of
substring
counted from the character located at
the position specified by the third argument.
boolean isAscii(
string arg)
;
The isAscii(string)
function takes one
string argument and returns a boolean value depending on whether
the string can be encoded as an ASCII string (true) or not
(false).
boolean isBlank(
string arg)
;
The isBlank(string)
function takes one
string argument and returns a boolean value depending on whether
the string contains only white space characters (true) or not
(false).
boolean isDate(
string arg, string pattern)
;
The isDate(string, string)
function
accepts two string arguments. It takes them, compares the first
argument with the second as a pattern and, if the first string can
be converted to a date which is valid within system value of
locale
, according to the specified
pattern
, the function returns true. If it is
not possible, it returns false.
(For more details, see another version of the
isDate()
function below - the
isDate(string, string, string, boolean)
function.)
This function is a variant of the mentioned
isDate(string, string, string)
function in which the default value of the third argument is set
to system value.
boolean isDate(
string arg, string pattern, string locale)
;
The isDate(string, string, string)
function accepts three string arguments. It takes them, compares
the first argument with the second as a pattern, use the third
argument (locale
) and, if the first string can
be converted to a date which is valid within specified
locale
, according to the specified
pattern
, the function returns true. If it is
not possible, it returns false.
(For more details, see another version of the
isDate()
function below - the
isDate(string, string, string, boolean)
function.)
See http://java.sun.com/j2se/1.6.0/docs/api/java/util/Locale.html for details about Locale.
boolean isInteger(
string arg)
;
The isInteger(string)
function takes one
string argument and returns a boolean value depending on whether
the string can be converted to an integer number (true) or not
(false).
boolean isLong(
string arg)
;
The isLong(string)
function takes one
string argument and returns a boolean value depending on whether
the string can be converted to a long number (true) or not
(false).
boolean isNumber(
string arg)
;
The isNumber(string)
function takes one
string argument and returns a boolean value depending on whether
the string can be converted to a double (true) or not
(false).
boolean isUrl(
string arg)
;
The function checks whether specified string is a valid URL of the following syntax
foo://username:passw@host.com:8042/there/index.dtb?type=animal;name=cat#nose \_/ \____________/ \______/ \__/\______________/ \__________________/ \__/ | | | | | | | protocol userinfo host port path query ref
See http://www.ietf.org/rfc/rfc2396.txt for more info about the URI standards.
string join(
string delimiter, <element type>[] arg)
;
The join(string, <element type>[])
function accepts two arguments. The first is
string, the second is a list of elements of any data type.
The elements that are not strings are
converted to their string representation and put together with the
first argument as delimiter.
string join(
string delimiter, map[<type of key>,<type of value>] arg)
;
The join(string, map[<type of key>,<type of value>])
function accepts two arguments. The first is
string, the second is a map of any data types.
The map elements are displayed as key=value
strings.
These are put together with the
first argument as delimiter.
string left(
string arg, integer length)
;
The left(string, integer)
function
accepts two arguments: the first is string and the second is integer.
It takes them and returns the substring of the
length specified as the second argument counted from the start of
the string specified as the first argument. If the input string is shorter
than the length
parameter, an exception is thrown
and the graph fails. To avoid such failure, use the
left(string, integer, boolean)
function described below.
string left(
string arg, integer length, boolean spacePad)
;
The function returns prefix of the specified length. If the input string
is longer or equally long as the length
parameter, the function behaves the same way as the
left(string, integer)
function. There is different
behaviour if the input string is shorter than the specified length. If the
3th argument is true
,
the right side of the result is padded with blank spaces so that the
result has specified length beeing left justified. Whereas if false
,
the input string is returned as the result with no space added.
integer length(
structuredtype arg)
;
The length(structuredtype)
function
accepts a structured data type as its argument:
string
,
<element type>[]
, map[<type of key>,<type of value>]
or
record
. It takes the argument and returns a
number of elements forming the structured data type.
string lowerCase(
string arg)
;
The lowerCase(string)
function takes one
string argument and returns another string with cases converted to
lower cases only.
boolean matches(
string arg, string regex)
;
The matches(string, string)
function takes two
string arguments. The second argument is some
regular expression. If the first argument can be expressed with such regular expression,
the function returns true
, otherwise it is false
.
string metaphone(
string arg, integer maxLength)
;
The metaphone(string, integer)
function
accepts one string argument and one integer meaning the maximum
length. The function takes these arguments and returns the
metaphone code of the first argument of the specified maximum
length. The default maximum length is 4. For more information, see
the following site: www.lanw.com/java/phonetic/default.htm.
string NYSIIS(
string arg)
;
The NYSIIS(string)
function takes one
string argument and returns the New York State Identification and
Intelligence System Phonetic Code of the argument. For more
information, see the following site: http://en.wikipedia.org/wiki/New_York_State_Identification_and_Intelligence_System.
string randomString(
integer minLength, integer maxLength)
;
The randomString(integer, integer)
function
takes two integer arguments and returns strings composed of
lowercase letters whose length varies between
minLength
and maxLength
.
These resulting strings are generated at random for records and
fields. They can be different for both different records and
different fields. Their length can also be equal to
minLength
or maxLength
,
however, they can be neither shorter than
minLength
nor longer than
maxLength
.
string
randomUUID(
)
;
Generates a random but undoubtedly unique string identifier. The generated string has this format:
hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh
where h
belongs to [0-9a-f]
.
In other words, you generate a hexadecimal code of a random 128bit
number.
Example generated string: cee188a3-aa67-4a68-bcd2-52f3ec0329e6
For more details on the algorithm used, browse the Java documentation.
string
removeBlankSpace(
string arg)
;
The removeBlankSpace(string)
function
takes one string argument and returns another string with white
spaces removed.
string
removeDiacritic(
string arg)
;
The removeDiacritic(string)
function
takes one string argument and returns another string with
diacritical marks removed.
string removeNonAscii(
string arg)
;
The removeNonAscii(string)
function
takes one string argument and returns another string with
non-ascii characters removed.
string
removeNonPrintable(
string arg)
;
The removeNonPrintable(string)
function
takes one string argument and returns another string with
non-printable characters removed.
string replace(
string arg, string regex, string replacement)
;
The replace(string, string, string)
function takes three string arguments - a string, a
regular expression,
and a replacement - and replaces all regex matches inside the string
with the replacement string you specified. All parts of the string
that match the regex are replaced. You can also reference the matched
text using a backreference in the replacement string. A backreference
to the entire match is indicated as $0. If there are capturing parentheses,
you can reference specifics groups as $1, $2, $3, etc.
replace("Hello","[Ll]","t")
returns
"Hetto"
replace("Hello", "e(l+)", "a$1")
returns "Hallo"
Important - please beware of similar syntax of $0, $1 etc. While used inside the replacement string it refers to matching regular expression parenthesis (in order). If used outside a string, it means a reference to an input field. See other example:
replace("Hello", "e(l+)", $0.name)
returns HJohno
if input
field "name" on port 0 contains the name "John".
You can also use modifier in the start of the regular expression:
(?i)
for case-insensitive search, (?m)
for multiline
mode or (?s)
for "dotall" mode where a dot (".") matches even a
newline character
replace("Hello", "(?i)L", "t")
will produce Hetto
while replace("Hello", "L", "t")
will just produce Hello
string right(
string arg, integer length)
;
The right(string, integer)
function
accepts two arguments: the first is string and the second is integer.
It takes them and returns the substring of the
length specified as the second argument counted from the end of
the string specified as the first argument. If the input string is shorter
than the length
parameter, an exception is thrown
and the graph fails. To avoid such failure, use the
right(string, integer, boolean)
function described below.
string right(
string arg, integer length, boolean spacePad)
;
The function returns suffix of the specified length. If the input string
is longer or equally long as the length
parameter, the function behaves the same way as the
right(string, integer)
function. There is different
behaviour if the input string is shorter than the specified length. If the
3th argument is true
,
the left side of the result is padded with blank spaces so that the
result has specified length beeing right justified. Whereas if false
,
the input string is returned as the result with no space added.
string soundex(
string arg)
;
The soundex(string)
function takes one
string argument and converts the string to another. The resulting
string consists of the first letter of the string specified as the
argument and three digits. The three digits are based on the
consonants contained in the string when similar numbers correspond
to similarly sounding consonants. Thus,
soundex("word")
returns
"w600"
.
string[] split(
string arg, string regex)
;
The split(string, string)
function
accepts two string arguments. The second is some regular
expression. It is searched in the first string argument and if it
is found, the string is split into the parts located between the
characters or substrings of such a regular expression. The
resulting parts of the string are returned as a list of strings. Thus,
split("abcdefg", "[ce]")
returns
.["ab"
, "d"
,
"fg"
]
string substring(
string arg, integer
fromIndex, integer length)
;
The substring(string, integer, integer)
function accepts three arguments: the first
is string and the other two are integers.
The function takes the
arguments and returns a substring of the defined length obtained
from the original string by getting the length
number of characters starting from the position defined by the
second argument.
Thus, substring("text", 1, 2)
returns
"ex"
.
string translate(
string arg, string
searchingSet, string replaceSet)
;
The translate(string, string, string)
function accepts three string arguments. The number of characters
must be equal in both the second and the third arguments. If some
character from the string specified as the second argument is
found in the string specified as the first argument, it is
replaced by a character taken from the string specified as the
third argument. The character from the third string must be at the
same position as the character in the second string. Thus,
translate("hello", "leo", "pii")
returns
"hippi"
.
string trim(
string arg)
;
The trim(string)
function takes one
string argument and returns another string with leading and
trailing white spaces removed.
string unescapeUrl(
string arg)
;
The function decodes escape sequences of illegal characters within components
of specified URL (see isUrl() CTL2 function
for the URL component description).
Escape sequences consist of
a percent character %
symbol, followed by the two-digit hexadecimal
representation (case-insensitive) of the ISO-Latin code point for
the character, e.g., %20
is the escaped encoding
for the US-ASCII space character.
string upperCase(
string arg)
;
The upperCase(string)
function takes one
string argument and returns another string with cases converted to
upper cases only.