Java tutorial
//package com.java2s; //License from project: Apache License import java.util.regex.*; public class Main { public static String readValue(String whole, String key) { Pattern pattern = Pattern.compile(key + "=([\"'])(.+?)\\1", Pattern.CASE_INSENSITIVE); Matcher mat = pattern.matcher(whole); if (mat.find()) { return mat.group(2); } else { pattern = Pattern.compile(key + "=([^ \t\r\n\f\b\"'/>]+?)[ \t\r\n\f\b\"'/>]", Pattern.CASE_INSENSITIVE); mat = pattern.matcher(whole); if (mat.find()) { return mat.group(1); } } return ""; } }