我有一个像这样的字符串
<some other tags and things> <span style="color: #e23d39;"><strong><span style="color: #2873ee;">Some Text</span></strong></span> <some other tags and things>
我想用样式提取每个跨度,然后用其他标记替换它。例如来自该字符串。 我想匹配
<span style="color: #e23d39;"><strong><span style="color: #2873ee;">Some Text</span></strong></span>
在第一场比赛中,获取第一个范围的样式颜色并将其替换为
<font color="#e23d39"><strong><span style="color: #2873ee;">Some Text</span></strong></font>
然后再次匹配,这是我想要的最终字符串。
<font color="#e23d39"><strong><font color= "#2873ee">Some Text</font></strong></font>
我正在使用Java的.replaceAll
函数,所以没有问题。
但是使用正则表达式:
/<span\s*?style="(.*?)">((?:.|\n)*?)<\/span>/g
在第一次运行中需要:
<span style="color: #e23d39;"><strong><span style="color: #2873ee;">Some Text</span>
并离开另一部分:
</strong></span>
那么正确的正则表达式是什么?或者我该如何解决这个问题呢?