Java tutorial
//package com.java2s; public class Main { public static int getIntFromString(String s) { String tmp = s.replaceAll("[^\\d]", ""); if (!tmp.isEmpty()) { return Integer.parseInt(tmp); } else { return 0; } } }