String Function 11.7
String Function 11.7
7)
Use the string functions to manipulate strings.
The following functions are in the String category of the expression editor. Square brackets
indicate that an argument is optional. The examples show the function as it appears in
a Derivation field in the Transformer stage.
AlNum
Checks whether the given string contains only alphanumeric characters.
AlNum(mylink.mystring2)
Alpha
Checks whether the given string contains only alphabetic characters.
Alpha(mylink.mystring2)
Change
Replaces the given substring in an expression with a replacement string. If
the substring argument is an empty string, the value of the expression argument is
returned. If the value of the replacement argument is an empty string, all
occurrences of the substring starting from the position indicated by the value of
the begin argument are removed. If the value of the occurrence argument is less
than or equal to 0, all occurrences starting from the position indicated by the value
of the begin argument are replaced. Otherwise, the number of occurrences that are
replaced is indicated by the value of the occurrence argument, starting from the
position indicated by the value of the begin argument. If the value of
the begin argument is less than or equal to 1, the replacement starts from the first
occurrence. Otherwise, the replacement starts from the position indicated by the
value of thebegin argument.
Change(mylink.mystring,"bbb","ZZZ")
Change(mylink.mystring,"","ZZZ")
CompactWhiteSpace
Returns the string after reducing all consecutive white space to a single space.
Compare
Compares two strings for sorting. The comparison can be left-aligned (the default)
or right-aligned. A right-aligned comparison compares numeric substrings within
the specified strings as numbers. The numeric strings must occur at the same
character position in each string. For example, a right-aligned comparison of the
strings AB100 and AB99 indicates that AB100 is greater than AB99 since 100 is
greater than 99. A left-aligned comparison of the strings AC99 and AB100 indicates
that AC99 is greater since C is greater than B.
CompareNoCase
Compares two strings for sorting, ignoring their case.
CompareNum
Compares the first n characters of two strings.
CompareNumNoCase
Compares the first n characters of two strings, ignoring their case.
Conversion
Converts a string to a specified internal or external storage format.
The string expression evaluates the string to be converted.
The following table shows the values that you can specify for the conv_code
and conv_mode. If you specify I for conv_mode, the ICONV() function is
used for the conversion. If you specify O for conv_mode,
the OCONV() function is used for the conversion.
conv_code conv_mode Description
MX I Converts the input string from hexadecimal to decimal.
MB I Converts the input string from binary to decimal.
MX0C I Converts the input string from hexadecimal to ASCII character string.
MB0C I Converts the input string from binary to ASCII character string.
MX O Converts the input string from decimal to hexadecimal.
MB O Converts the input string from decimal to binary.
MX0C O Converts the input string from ASCII character string to hexadecimal.
MB0C O Converts the input string from ASCII character string to binary.
Table 1. Values for the conv_code and conv_mode.
Conversion(mylink.mystring,"MB", "I")
Conversion(mylink.mystring,"MX0C", "O")
Convert
Converts the characters in the string that is designated in the given expression.
Converts the characters that are specified in one list to the characters specified in
another list.
Count
Counts the number of times a substring occurs in a string.
Dcount
Counts the number of delimited fields in a string.
Input: string (string), delimiter (string)
Output: result (int32)
Examples. If mylink.mystring1 contains the string "chocolate drops, chocolate
ice cream, chocolate bars", then the following function returns 3.
Dcount(mylink.mystring1,",")
DownCase
Changes all uppercase letters in a string to lowercase letters.
DQuote
Encloses a string in double quotation marks.
Ereplace
Replaces a substring in an expression with replacement string. If
the substring argument is an empty string, the value of the replacement argument is
prefixed with the value of the expression argument. If the replacement argument is
an empty string, all occurrences of the substring starting from the position indicated
by the value of the begin argument are removed. If the value of
the occurrence argument is less than or equal to 0, all occurrences starting from the
value of the begin argument are replaced. Otherwise, the number of occurrences that
are replaced is indicated by the value of the occurrence argument, starting from the
position indicate by the value of the begin argument. If value of the begin argument
is less than or equal to 1, the replacement starts from the first occurrence.
Otherwise, the replacement starts from the position indicated by the value of
the begin argument.
Ereplace(mylink.mystring,"","ZZZ")
Field
Returns one or more substrings that are located between specified delimiters in a
string. The argument occurrence specifies which occurrence of the delimiter is to be
used as a terminator. The argument number optionally specifies how many
substrings to return.
Field(mylink.mystring1,",",2,2)
Index
Finds the starting character position of a substring. The
argument occurrence specifies which occurrence of the substring is to be located.
Left
Returns the leftmost n characters of a string.
Len
Returns the length of a string in characters.
Num
Returns 1 if the string can be converted to a number, or returns 0 otherwise.
Num(mylink.mystring1)
PadString
Returns the string padded with the specified number of pad characters.
Right
Returns the rightmost n characters of a string.
Soundex
Returns a code that identifies a set of words that are (roughly) phonetically alike
based on the standard, open algorithm for SOUNDEX evaluation.
Soundex(mylink.mystring1)
Space
Returns a string of n space characters.
StripWhiteSpace
Returns the string after removing all white space characters from it.
Trim
Removes all leading and trailing spaces and tabs. The function also reduces the
internal occurrences of spaces or tabs to one. The argument stripchar optionally
specifies a character other than a space or a tab. The argument options optionally
specifies the type of trim operation to be performed and contains one or more of the
following values:
Trim(mylink.mystring,".")
Trim(mylink.mystring,".","A")
Trim(mylink.mystring,".","T")
TrimB
Removes all trailing spaces and tabs from a string.
TrimF
Removes all leading spaces and tabs from a string.
TrimLeadingTrailing
Removes all leading and trailing spaces and tabs from a string.
UpCase
Changes all lowercase letters in a string to uppercase.
UpCase(mylink.mystring1)