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.

13-03-_2017_11-51-09.jpg

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.


13-03-_2017_16-40-45.jpg

If there is a better way to accomplish this I would be glad to learn something new.
 
Top