In html need replace url to tag
Only http://google3.com:1139 and http://google6.com:1139
<div>
<a href="http://google1.com:1139" target="_blank">http://google2.com:1139</a>
http://google3.com:1139
</div>
<div>
<a href="http://google4.com:1139" target="_blank">http://google5.com:1139</a>
http://google6.com:1139
</div>
Must be
<div>
<a href="http://google1.com:1139" target="_blank">http://google2.com:1139</a>
<a href="http://google3.com:1139" target="_blank">http://google3.com:1139</a>
</div>
<div>
<a href="http://google4.com:1139" target="_blank">http://google5.com:1139</a>
<a href="http://google6.com:1139" target="_blank">http://google6.com:1139</a>
</div>
var result = Regex.Replace("<div><a href=\"http://google1.com:1139\" target=\"_blank\">http://google2.com:1139</a>http://google3.com:1139</div><div><a href=\"http://google4.com:1139\" target=\"_blank\">http://google5.com:1139</a>http://google6.com:1139</div>",
@"((?<!href=['""]?)(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)",
"<a target='_blank' href='$1'>$1</a>");
But need replace
started with http but now with href="http (found)
not ended with
</a>
- or skip between
<a ... </a>