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”