The CHAR_MATCHCOUNT function of MaxCompute calculates the number of characters that are the same between two specified strings. This topic describes the syntax and parameters of the CHAR_MATCHCOUNT function. This topic also provides examples on how to use this function.
Syntax
bigint char_matchcount(string <str1>, string <str2>)
Parameters
str1 and str2: required. Values of the STRING type. The values must be valid UTF-8 strings. If invalid characters (non-Unicode-encoded characters) are found during the comparison of the two strings, this function returns 0
.
Return value
A value of the BIGINT type is returned. If the value of str1 or str2 is null, null is returned.
Examples
Example 1: Calculate the number of characters that belong to the string
aabc
and appear in the stringabcde
. Sample statement:-- The return value is 4. select char_matchcount('aabc','abcde');
Example 2: An input parameter is set to null. Sample statement:
-- The return value is null. select char_matchcount(null,'abcde');
Related functions
CHAR_MATCHCOUNT is a string function. For more information about functions related to string searches and conversion, see String functions.