I bumped into an interesting situation while I am writing an application about contact list.
The weird situation is that after I successfully managed to retrieve contacts from the iPhone's list, some phone numbers listed as;
@"\U0000202a xxx xxx xxxx\U0000202c".
When I try to use;
modifiedPN = [modifiedPN stringByReplacingOccurrencesOfString:@" " withString:@""];
and
modifiedPN = [modifiedPN stringByReplacingOccurrencesOfString:@"\\U0000202" withString:@""];
nothing changes.
I also tried
[mPN containsString:@" "]
and
[mPN containsString:@"\\U0000202"]
but they both returns "NO"
I think this problem occurs when user was saved from Whatsapp.
Does anyone know how to fix this issue?
I only want the phone number without spaces or weird \U0000202 charachter.
Go the other way and extract the number:
NSString *numString = @"\U0000202a 123 456 7890\U0000202c";
NSString *extractedString = [[numString componentsSeparatedByCharactersInSet:
[[NSCharacterSet decimalDigitCharacterSet] invertedSet]]
componentsJoinedByString:@""];
// extractedString = 1234567890
This also works with (123) 456 7890