s=s.replaceAll("[*a-zA-Z]", "") replaces all alphabets
s=s.replaceAll("[*0-9]", "") replaces all numbers
if you do over two replacements, you will get the whole special string
If you want to extract only integers from String s=s.replaceAll("[^0-9]", "")
If you want to extract only alphabets from String s=s.replaceAll("[^a-zA-Z]", "")
Happy coding :)
Mallikarjuna Sangisetty May 24 '14 at 11:30 a.m. 2014-05-24 11:30
source share