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.
Comments
Post a Comment