Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static Matcher sIntMatcher = Pattern.compile("^-?[0-9]+").matcher(""); public static int parseInt(String s) { Matcher m = sIntMatcher.reset(s); if (!m.find()) return Integer.MIN_VALUE; return Integer.parseInt(m.group(0)); } }