Java tutorial
//package com.java2s; public class Main { public static String stripNonNumeric(String str) { if (str == null) return null; String s = ""; int n = str.length(); char c; for (int i = 0; i < n; i++) { c = str.charAt(i); if (Character.isDigit(c)) s += c; } return s; } }