首页 > 解决方案 > How to replace html tags but keep the text in between?

问题描述

I'd like to keep the text in between the span tags. But there's something wrong with the replace expression...

I'm using Calibre text editor.

    Find:
    <span class="Heading3-strong">(.*?)</span>
    Replace:
    <strong>(.*?)</strong>

    Input:
    <span class="Heading3-strong">some text goes here</span>
    Output:
    <strong>some text goes here</strong>

标签: htmlregextext-editor

解决方案


替换模式不能是正则表达式,它是一个普通字符串,可能包含反向引用,形式为\nwhere nis group ID(它们从 开始1)。

所以,在你的情况下,你需要使用

<strong>\1</strong>

\1与 匹配的文本在哪里(.*?)

在这里查看更多信息。


推荐阅读