Java tutorial
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final Pattern patternTitle = Pattern.compile("<title>([^<]*)</title>"); public static String extractTitle(String html) { if (html == null) { return null; } Matcher matcher = patternTitle.matcher(html); if (matcher.find()) { String title = matcher.group(1); if (title != null) { title = title.trim(); } return title; } return null; } }