我有一个看起来像这样的段落:
First.Check out this <a href="https://sample.com/applications/Documents/SolutionContingency.html" target="_blank">demo </a>to learn about the Solution Contingency feature of MME.
Second Paragraph. Get your head out of the fog and use the solution contingency feature in MME! All the costs for a WMU are displayed on the Costs screen in the Forecast menu.
<a href="https://blog.sample.com/mme/files/2013/07/SC2.jpg"><img title="SC2" alt="" src="https://blog.sample.com/mme/files/2013/07/SC2.jpg" width="1262" height="711" /></a>
Fourth.You should review your solution contingency at least once a month.
我刚刚使用带有空字符串的正则表达式替换了图像网址:
(<a.*?<img.*?>.*?/a>|<img.*?>)
您是否知道为什么输出会从图片上的超链接中删除。它只显示第一和第四段。
这是输出:
First.Check out this Fourth.You should review your solution contingency at least once a month.
当段落没有超链接时,删除图片工作正常。
答案 0 :(得分:0)
我不是100%肯定你在追求什么。如果您只想隔离图片代码,可以将正则表达式更改为以下内容:(<img.*?>)