Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * Returns just the numbers of a String * @param s Charsequence to analyze * @return String, containing only numbers */ public static String keepNumbersOnly(CharSequence s) { try { return s.toString().replaceAll("[^0-9]", ""); } catch (Exception e) { return null; } } }