Java tutorial
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern p = Pattern.compile("\\d\\d?\\d?"); Matcher m = p.matcher("test this 536 in it"); while (m.find()) { System.out.println(m.group()); // print the age in your string System.out.println(m.start()); // print the position in the string where it starts } } }