I am trying to get Numeric from the string. I have string with phone number so I need numerics only.
My string format is:
P: 000-000-0000
So I am using following code for that:
[[strPhone componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];
In few cases I am getting following format for my string:
P: 000 000 0000 M: 000 000 0000
What I want to do is.. I want to split my string in an array. for that purpose I need to split my string from the characters.
Is there any way to achive this thing.
In case that if we have
P: 000 000 0000 Mo: 000 000 0000 format then the array should have only two parts. One should split with “P” and second with “Mo”. not the three part one with “P”, Second “M”, third “o”.
Plz help me to achive this.
Thanks
You could split up the data first to detect multiple numbers in one string using
Then loop over the candidates and perform your previous phone number check and remove all empty strings from the result, e.g.