Here you can find the source of extractNumbers(String text)
public static String[] extractNumbers(String text)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static String[] extractNumbers(String text) { if (isEmpty(text)) return new String[] {}; String[] tmp = text.split("\\D"); List<String> list = new ArrayList<String>(); for (String s : tmp) { if (s.length() > 0) { list.add(s);//w w w . ja v a2 s. com } } return list.toArray(new String[0]); } public static boolean isEmpty(Object object) { if (object == null) return true; if (object instanceof String && object.toString().length() == 0) return true; return false; } }