filter number from Phone book by replacing all special characters in Android? -
i working contacts fetched default phone book in android. when fetch contacts phone book, sometime getting "-", "(" etc characters.
if characters known can remove them relpace() method client complaint times got see % symbols in number fetch phone book.
please suggest me, how can filter numbers fetch phone book, can have only , digits in text field , no else characters.
currently using string.replace("-","");
removing '-' contact number.
you can use phonenumberutils.stripseparators(string)
(available in api 1+).
edited
or can use regular expression:
filternum = filternum.replaceall("[^0-9]+", "");
— remove characters not in range 0...9
. think easier. here's the documentation.
Comments
Post a Comment