I have to extract only numeric values from String str=\"sdfvsdf68fsdfsf8999fsdf09\". How can I extract numbers from an alpha numeric string in android?
String str=\"sdfvsdf68fsdfsf8999fsdf09\"
public static String getOnlyNumerics(String str) { if (str == null) { return null; } StringBuffer strBuff = new StringBuffer(); char c; for (int i = 0; i < str.length() ; i++) { c = str.charAt(i); if (Character.isDigit(c)) { strBuff.append(c); } } return strBuff.toString(); }