Android Question [Solved] How do remove emoticons characters from a string?

sorex

Expert
Licensed User
Longtime User
it depends on how they are added. if they all use something like [smile] or :smile: it's easy.

if it is a mix of things you probably need to use a loop with replacement parameters to use with regex.replace
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks. Works fine.
I just change the decimal number to 256 to include accents in the string.

B4X:
Sub RemoveEmojis(s As String) As String
    Dim sb As StringBuilder
    sb.Initialize
    For i = 0 To s.Length - 1
        Dim c As String = s.CharAt(i)
        If Asc(c) < 256 Then sb.Append(c)
    Next
    Return sb.ToString
End Sub
 
Upvote 0
Top