正则表达式ex1

来源:互联网 发布:mac桌面日历 编辑:程序博客网 时间:2024/06/08 00:32
 void DumpHrefs(String inputString)
    {
        Regex r;
        Match m;

        r = new Regex("href//s*=//s*(?:/"(?<1>[^/"]*)/"|(?<1>//S+))",
            RegexOptions.IgnoreCase|RegexOptions.Compiled);
        for (m = r.Match(inputString); m.Success; m = m.NextMatch())
        {
            Console.WriteLine("Found href " + m.Groups[1] + " at "
                + m.Groups[1].Index);
        }
    }
原创粉丝点击