Skip to content
Advertisement

Remove character ‘u202A’ 8234 from string

I am trying to get character at 0 index in a string:

JavaScript

So I use this function after I query contact, but I found strange result.

Normal input & output:

JavaScript

And this the strange input and result:

JavaScript

So I try to debug this account and I found when app try to get character at 0 the return is ‘u202A’ 8234, not 0.

I already tried RegEx like:

JavaScript

All of them return same value ‘u202A’ 8234.

What is this character? How to fix this problem?

Update : I try to edit the strange contact and I found strange behaviour. The number is 011111111111. First I put cursor between 0 and 1, then I press delete/backspace to remove 0. The cursor suddenly move to the right of number 1 not on the left. Then I save the contact and run my program. The result is 0, not ‘u202A’ 8234. So I think this because the format of number not normal, maybe when first time add this contact or when sync from the google account.

Advertisement

Answer

Finally, I found out that I can use regex to replace non-Alphanumeric characters.

So this is my finale function :

JavaScript

This regex remove all unicode characters beside Alphanumeric characters.

Advertisement