Here you can find the source of getFirstInteger(String value)
public static int getFirstInteger(String value)
//package com.java2s; public class Main { public static int getFirstInteger(String value) { StringBuilder sb = new StringBuilder(); char[] charArray = value.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (charArray[i] >= '0' && charArray[i] <= '9') { sb.append(charArray[i]); } else { break; }/*from w ww . ja va 2s .c om*/ } return (sb.length() == 0 ? 0 : Integer.parseInt(sb.toString())); } }