|
Sub-Strings
STR_LEFT(<str-expr>, <num-expr>) Left N characters
This function returns a string value, equal to the left N characters of the first function operand, where N is the value of the second function operand (rounded to an integer).
For example, STR_LEFT("abcdef", 3) returns the string "abc".
STR_RIGHT(<str-expr>, <num-expr>) Right N characters
This function returns a string value, equal to the right N characters of the first function operand, where N is the value of the second function operand (rounded to an integer).
For example, STR_RIGHT("abcdef", 4) returns the string "cdef".
Note that STR_LEFT and STR_RIGHT can be combined in order to obtain any sub-string from a given string. For instance, STR_RIGHT(STR_LEFT("abcdef", 4), 2) returns the string "cd".
Both functions will generate runtime errors if the numeric argument is invalid (For example, if it is negative).
STR_SEARCH(<str-expr>, <str-expr>) Search sub-string
This function returns a numeric value, defined as follows:
-
The first argument is the source string, where a sub-string is searched.
-
The second argument is a sub-string to search inside the source string.
-
If the sub-string is found, the returned number is the position in the source string of the first occurrence of the sub-string (the first character is position 1).
-
If the sub-string is not found, the function returns 0.
The two function arguments must be separated by a comma.
Example
STR_SEARCH("abcdef", "a") returns 1.
STR_SEARCH("123123123", "31") returns 3.
STR_SEARCH("123123123", "ab") returns 0.
|