EGL library strLib
The strLib functions manipulate and convert data to and from STRING variables and format date/time variables.
The following table shows the system functions in the strLib library. Subsequent tables show the strLib variables and constants.
| System function and invocation | Description |
|---|---|
| result = base64Decode (text ) | Returns the BASE64 decoded value of the input string. |
| result = base64Encode (text ) | Returns the BASE64 encoded value of the input string. |
| result = booleanAsString (value ) | Returns the string "true" or the string "false" based on a Boolean value. |
| result = byteLen (source ) | Returns the number of bytes in a variable, excluding any trailing spaces and null values. |
| result = characterLen (source) | Returns the number of characters in a text expression, excluding any trailing spaces or null values. |
| result = charAsInt (text ) | Returns an integer code point corresponding to a character. |
| result = charAt (index ) | Returns the char value at the specified index of the string. In EGL strings start from index 1. |
| result = clip (text [, code]) | Deletes leading/trailing blanks and nulls from character strings. |
| result = concatenateStrings (text ) | Returns the combined string obtained by appending the second string to the end of the first one. |
| result = Contains (target, sequence ) | Checks whether a string contains a sequence of characters or not. |
| result = contentEquals (target, sequence ) | Searches a string to find out if it contains the exact same sequence of characters in the specified string. Returns true if the characters exist and false if not. |
| result = endsWith (target, suffix ) | Checks whether the string ends with the specified character(s). It has a new optional parameter for ignoring or not upper/lower cases. |
| result = equals (target, text ) | Compares two strings, and returns true if the strings are equal, false if they are not. |
| result = equalsIgnoreCase (target, text ) | Compares two strings, ignoring lowercase and uppercase differences, and returns true if the strings are equal, false if not. |
result = formatDate (dateValue |
Formats a DATE value and returns a STRING value. |
result = formatNumber (numericExpression, |
Returns a number as a formatted string. |
result = formatTime (timeValue |
Formats a parameter into a time value and returns a STRING value. The default format is the format specified in the current locale. |
result = formatTimestamp (timestampValue |
Formats a parameter into a timestamp value and returns a value of type STRING. The DB2® format is the default format. |
token = getNextToken (source, index, |
Returns the next token in a string. |
| result = getTokenCount (source, delimiters) | Returns the number of tokens in a source string. |
| result = indexOf (source, pattern [, startPosition] ) | Returns an index into a string of characters. The index indicates where a specified pattern begins. |
| result = intAsChar (integer) | Returns a character that corresponds to an integer code point. |
| result = intAsUnicode (integer) | Returns a Unicode character that corresponds to an integer code point. |
| result = isEmpty (boolean ) | Checks if a string is empty to return “true” otherwise it returns “false”. |
| result = isMatch (target, regex ) | Checks whether this string matches the given regular expression (ReGeX). |
| result = Join (target, delimiter ) | Concatenates the given element with the delimiter and returns the concatenated string. |
| result = lastIndexOf (target, element ) | Returns the position of the last occurrence of specified character(s) in a string. |
| result = length (integer ) | Returns the number of characters in the string. |
| result = lowerCase (text) | Returns a copy of a character-type value and sets all the uppercase characters in that copy to lowercase. If the input value is of a type other than String, a data conversion strips trailing blanks from the input value before the function is invoked. |
| result = lowerCaseChar (text) | Returns a copy of a character-type value and sets all the uppercase characters in that copy to lowercase. The function retains trailing blanks. |
| result = replaceAll (target, text, text ) | Returns a new string where all the characters matching the ReGeX are replaced with the replacement string. |
| result = replaceFirst (target, text, text ) | Returns a new string where the first occurrence of the matching substring is replaced with the replacement string. |
| result = replaceSubStr (target, text, text ) | Searches a string for a specified character and returns a new string where the specified characters are replaced. |
| setBlankTerminator (target) | Replaces a null terminator and any subsequent characters in a string with spaces. |
| setNullTerminator (target) | Changes all trailing spaces in a string to null values. |
| result =spaces (characterCount) | Returns a string of a specified length. |
| result = Split (text ) | Splits a string into an array of substrings based on a specified delimiter. |
| result = startsWith (target, prefix ) | Checks whether the string starts with the specified prefix. |
| result = subsequence (target, index, index ) | Returns a character sequence that represents a subsequence of the original sequence, based on the specified starting index (inclusive) and ending index (exclusive). |
| result = substring (text ) | Used to retrieve a portion of a string. |
| result = unicodeAsInt (integer) | Returns an integer that corresponds to a Unicode character. |
| result = upperCase (text) | Returns a copy of a character-type value and sets all the lowercase characters in that copy to uppercase. If the input value is of a type other than String, a data conversion strips trailing blanks from the input value before the function is invoked. |
| result = upperCaseChar (text) | Returns a copy of a character-type value and sets all the lowercase characters in that copy to uppercase. The function retains trailing blanks. |
Variables
The following table shows the system variables in the strLib library.
| System variable | Description |
|---|---|
| defaultDateFormat | Specifies a default pattern to convert a DATE to text. |
| defaultMoneyFormat | Specifies a default pattern to convert a MONEY type to text. |
| defaultNumericFormat | Specifies a default pattern to convert a number to text. |
| defaultTimeFormat | Specifies a default pattern to convert a TIME to text. |
| defaultTimestampFormat | Specifies a default pattern to convert a TIMESTAMP to text. |
Constants
The following table shows the system constants in the strLib library.
| System constant | Description |
|---|---|
| db2TimestampFormat | The pattern yyyy-MM-dd-HH.mm.ss.SSSSSS, which is the IBM® DB2® default timestamp format. |
| eurDateFormat | The pattern dd.MM.yyyy, which is the IBM® European standard date format. |
| eurTimeFormat | The pattern HH.mm.ss, which is the IBM® European standard time format. |
| isoDateFormat | The pattern yyyy-MM-dd, which is the date format that the International Standards Organization (ISO) specifies. |
| isoTimeFormat | The pattern HH.mm.ss, which is the time format that the International Standards Organization (ISO) specifies. |
| jisDateFormat | The pattern yyyy-MM-dd, which is the Japanese Industrial Standard date format. |
| jisTimeFormat | The pattern HH:mm:ss, which is the Japanese Industrial Standard time format. |
| nullFill | The empty string (""), which is used to initialize a character variable to a null value. |
| odbcTimestampFormat | The pattern yyyy-MM-dd HH:mm:ss.SSSSSS, which is the Open Database Connectivity timestamp format. |
| usaDateFormat | The pattern MM/dd/yyyy, which is the IBM® USA standard date format. |
| usaTimeFormat | The pattern hh:mm a, which is the IBM® USA standard time format. |
Compatibility
| Platform | Issue |
|---|---|
| Rich UI | The following strLib functions are not supported:
|
| COBOL | The following strLib functions are not supported:
|