Android Question How to remove common letters in two string?

Pravee7094

Active Member
Hi all,
How to remove common letters in two strings?
B4X:
dim str1 as string = "GUNA"
dim str2 as string = "MANI"

Here I have two names in string variable, Here in the both names, 'A' and 'N' letter is common.
so I wanna remove those letter. and print remaining letters.

Any suggestion or help?

Thanks
 

Peter Meares

Member
Licensed User
Longtime User
A simple way is to work through one word, letter by letter, and check if the other word contains the letter. Then replace the relevant letter with nothing.
A second way would be to convert each word to a map and count each letter into the map. Then check the two maps against each other.
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Use regex:
 
Upvote 0
Top