求高手写一个正则
原字符串类似于这样
有图片链接的a标签,有文字的标签
<a href="1.html"><img src ..></a> <a href="1.html">文字</a><a href="2.html"><img src ..></a> <a href="2.html">文字</a><a href="3.html"><img src ..></a> <a href="3.html">文字</a>
<a href="1.html">文字</a><a href="2.html"><img src ..></a>
(?is)<a[^>]*><img(?><a[^>]*>(?<Open>)|</a>(?<-Open>)|(?:(?!</?a\b).)*)*(?(Open)(?!))</a>试试
[解决办法]
Regex reg = new Regex(@"(?is)(?<=<img)[^>]*?(?=>)");
[解决办法]
(?i)<a\b[^>]*?><img\b[^>]*?></a>
[解决办法]
Regex re = new Regex(@"<a[^>]*><img[^>]*></a>", RegexOptions.Singleline);MatchCollection mc = re.Matches("text");foreach (Match ma in mc){}