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

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -