C# 正则表达式 获取字符的问题如何获取到 网址 并循环输出呢? <ul><li><span>1.</span> <a href='http://s.ianhai.com' target=_blank>s.ianhai.com</a></li><li><span>2.</span> <a href='http://51tttg.com' target=_blank>51tttg.com</a></li><li><span>3.</span> <a href='http://www.ued6.com' target=_blank>www.ued6.com</a></li><li><span> </ul> 
我想要输出的内容是:
http://s.ianhai.com
http://51tttg.com
http://www.ued6.com

解决方案 »

  1.   

    (?i)(?<=<a\b[^>]*?href=(['"]))[^<>]+(?=\1)
      

  2.   


    string e="<ul><li><span>1.</span> <a href='http://s.ianhai.com' target=_blank>s.ianhai.com</a></li><li><span>2.</span> <a href='http://51tttg.com' target=_blank>51tttg.com</a></li><li><span>3.</span> <a href='http://www.ued6.com' target=_blank>www.ued6.com</a></li><li><span> </ul> ";string f = @"(?i)(?<=<a\b[^>]*?href=(['""]))[^<>]+(?=\1)";(这样对吗?)
    for(i)
                string g = Regex.Match(e, f).Value.ToString();然后如何用for循环输出 谢谢
      

  3.   

     MatchCollection mc = Regex.Matches(table, @"(?i)(?<=<a\b[^>]*?href=(['""]))[^<>]+(?=\1)")", RegexOptions.IgnoreCase);
                        foreach (Match m in mc)
    {}
    这样等到所有匹配的
      

  4.   

    string e="<ul><li><span>1.</span> <a href='http://s.ianhai.com' target=_blank>s.ianhai.com</a></li><li><span>2.</span> <a href='http://51tttg.com' target=_blank>51tttg.com</a></li><li><span>3.</span> <a href='http://www.ued6.com' target=_blank>www.ued6.com</a></li><li><span> </ul> "; string f = @"(?i)(?<=<a\b[^>]*?href=(['""]))[^<>]+(?=\1)"; 
    foreach(Match m in Regex.Matches(e,f))
    Console.WriteLine(m.Value);