Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String getFirstMatch(String html, String pattern) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(html); String result = ""; while (m.find()) { result = m.group(1); break; } return result; } }