Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static String extractPattern(String string, String pattern) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(string); if (!m.find()) { return null; } return m.toMatchResult().group(1); } }