Android Code Snippet Strip all Emoji-characters from a string

I needed a function that strips all Emoji characters but keeps language typical characters in a string.

The user used an Emoji as first character of the meal title, so the the searchview can't show it in the "Begins with" section but show it in the "Contains" section.

If the user would search for "Spaghetti" he expect it to be on top of the list. Any other position would put the user in a Cognitive dissonance.


After some research this RegexReplace seemed to be the one with the best performance:

B4X:
Dim strCleaned As String = Regex.Replace("[^\u0000-\u00FF]", strToClean, "")

You can change the range with help of the Unicode table.



If there is a better way to accomplish this I would be glad to learn something new.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…