java - Extract alphabets, space and comma from string in android -


i have string mixed numbers , alphabets below, doing following replacement

string fullstring = "08094 williamstown, new jersey";   string extractedstring = fullstring .replaceall("[^a-z^a-z]", ""); 

the result getting : williamstownnewjersey
want : williamstown, new jersey

how can ?
thank you.

your regex checks non-alphabets includes comma , spaces.

for case can try

string extractedstring = fullstring .replaceall("\\d", "").trim(); 

or

string extractedstring = fullstring .replaceall("[0-9]", "").trim(); 

you can check regex online here.

http://www.regexplanet.com/advanced/java/index.html


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -