日期:2014-05-20 浏览次数:21114 次
public static string[] GetRegValue(string HtmlCode, string RegexString, string GroupKey)
    {
        MatchCollection m;
        Regex r;
        r = new Regex(RegexString, RegexOptions.Multiline | RegexOptions.Singleline);
        m = r.Matches(HtmlCode);
        string[] MatchValue = new string[m.Count];
        for (int i = 0; i < m.Count; i++)
        {
            MatchValue[i] = m[i].Groups[GroupKey].Value;
        }
        return MatchValue;
    }
GetRegValue(text, "name=\"mailAddress\" type=\"text\" value=\"(?<id>.*?)\"", "id")[0];
    Pattern p = Pattern.compile("miibeian.*?>(.*?)<");
    Matcher m = p.matcher(" <a href=http://www.miibeian.gov.cn target=_blank>京ICP证030173号</a>");
    if(m.find()){
        System.out.println(m.group(1));
    }