String Functions Flashcards
ASCII
Returns the ASCII code for the first character of string.
Example:
ASCII(‘A’) = 65
CHAR
Returns the character encoded by the ASCII code number.
Example:
CHAR(65) = ‘A’
CONTAINS
Returns true if the given string contains the specified substring.
Example:
CONTAINS(“Calculation”, “alcu”) = true
ENDSWITH
Returns true if the given string ends with the specified substring. Trailing white spaces are ignored.
Example:
ENDSWITH(“Tableau”, “leau”) = true
FIND
Returns the index position of substring in string, or 0 if the substring isn’t found. If the optional argument start is added, the function ignores any instances of substring that appear before the index position start. The first character in the string is position 1.
Examples:
FIND("Calculation", "alcu") = 2 FIND("Calculation", "Computer") = 0 FIND("Calculation", "a", 3) = 7 FIND("Calculation", "a", 2) = 2 FIND("Calculation", "a", 8) = 0 FIND("Calculation", "a", 3) = 7 FIND("Calculation", "a", 2) = 2 FIND("Calculation", "a", 8) = 0
FINDNTH
Returns the position of the nth occurrence of substring within the specified string, where n is defined by the occurrence argument.
Note: FINDNTH is not available for all data sources.
Example:
FINDNTH(“Calculation”, “a”, 2) = 7
LEFT
Returns the left-most number of characters in the string.
Example:
LEFT(“Matador”, 4) = “Mata”
LEN
Returns the length of the string.
Example:
LEN(“Matador”) = 7
LOWER
Returns string, with all characters lowercase.
Example:
LOWER(“ProductVersion”) = “productversion”
LTRIM
Returns the string with any leading spaces removed.
Example:
LTRIM(“ Matador “) = “Matador “
MAX
Returns the maximum of a and b (which must be of the same type). This function is usually used to compare numbers, but also works on strings. With strings, MAX finds the value that is highest in the sort sequence defined by the database for that column. It returns Null if either argument is Null.
Example:
MAX (“Apple”,”Banana”) = “Banana”
MID
Returns the string starting at index position start. The first character in the string is position 1. If the optional argument length is added, the returned string includes only that number of characters.
Examples:
MID(“Calculation”, 2) = “alculation”
MID(“Calculation”, 2, 5) =”alcul”
MIN
Returns the minimum of a and b (which must be of the same type). This function is usually used to compare numbers, but also works on strings. With strings, MIN finds the value that is lowest in the sort sequence. It returns Null if either argument is Null.
Example:
MIN (“Apple”,”Banana”) = “Apple”
REPLACE
Searches string for substring and replaces it with replacement. If substring is not found, the string is not changed.
Example:
REPLACE(“Version8.5”, “8.5”, “9.0”) = “Version9.0”
RIGHT
Returns the right-most number of characters in string.
Example:
RIGHT(“Calculation”, 4) = “tion”
RTRIM
Returns string with any trailing spaces removed.
Example:
RTRIM(“ Calculation “) = “ Calculation”
SPACE
Returns a string that is composed of the specified number of repeated spaces.
Example:
SPACE(1) = “ “
SPLIT
Returns a substring from a string, using a delimiter character to divide the string into a sequence of tokens.
The string is interpreted as an alternating sequence of delimiters and tokens. So for the string abc-defgh-i-jkl, where the delimiter character is ‘-‘, the tokens are abc, defgh, i, and jlk. Think of these as tokens 1 through 4. SPLIT returns the token corresponding to the token number. When the token number is positive, tokens are counted starting from the left end of the string; when the token number is negative, tokens are counted starting from the right.
Examples:
SPLIT (‘a-b-c-d’, ‘-‘, 2) = ‘b’
SPLIT (‘a|b|c|d’, ‘|‘, -2) = ‘c’
STARTSWITH
Returns true if string starts with substring. Leading white spaces are ignored.
Example:
STARTSWITH(“Joker”, “Jo”) = true
TRIM
Returns the string with leading and trailing spaces removed.
Example:
TRIM(“ Calculation “) = “Calculation”
UPPER
Returns string, with all characters uppercase.
Example:
UPPER(“Calculation”) = “CALCULATION”