Java tutorial
//package com.java2s; public class Main { /** * Trim all non-numeric characters off of the string * * @param value * @return */ public static String trimNonNumericCharacters(String value) { //keep only numeric characters if (value != null) value = value.replaceAll("[^0-9]", ""); return value; } }