Java tutorial
//package com.java2s; import android.text.TextUtils; public class Main { public static String filterNum(String text) { if (TextUtils.isEmpty(text)) return ""; return text.replaceAll("[^0-9]", ""); } }