Find matching characters in 2 strings

Is there any way or in-built function in clover to find the matching characters in 2 strings.
(ie) compare the contents of two strings and return a string containing characters that appear in both of them.
Eg:
If I have str1 = “AXBYCZ”, str2 = “ABCDEF”
Then output should be = “ABC”

Also in similar lines if we compare 2 strings - if the first string content is same as the output then return TRUE.
(ie)
Eg:
If I have str1 = “ABC”, str2 = “AXBYCDEF”
Then output should be = 1

If I have str1 = “AXBYCZ”, str2 = “ABCDEF”
Then output should be = 0

Is there any way or built-in function in Clover to acheive the above 2 tasks?

Hi,
the first can be done somehow like this in CTL:

string str1;
string str2;
string target;

for(integer i=0;i<lenght(str1);i++){
string letter=charAt(str1,i);
if (contains(str2,letter) target=target+letter;
}

Basically I go through individual letters/characters of str1 and check whether they are included somewhere in str2. If yes then I add that letter to the target (result) string.

As for the other case - not sure what should be the logic. But you can use this example to deduce that piece of code you might need.