html - 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>
解决方案
替换模式不能是正则表达式,它是一个普通字符串,可能包含反向引用,形式为\n
where n
is group ID(它们从 开始1
)。
所以,在你的情况下,你需要使用
<strong>\1</strong>
\1
与 匹配的文本在哪里(.*?)
。
在这里查看更多信息。
推荐阅读
- ruby - 解释什么是 Ruby 元编程的示例
- angular - Angular [selected] 属性仅在 init 上运行
- python - 有没有办法使用带有默认字段的数据类和 __slots__
- webhooks - 对 Google 本地存储培训短语的操作
- javascript - React Native 的 FlatList proprenderItem 需要额外的“item”(item) => {item.item.name}?
- db2 - 未使用 DB2 ODBC 密码
- python - Python 2.7:更新列表中的元素
- php - 在 jQuery 中,我使用 ajax 在 codeigniter 中为搜索用户调用 api 但 respose 不显示
- sql - 将表定义克隆到 SQL Server 中的表变量
- php - 在 Codeigniter 上创建权限而不检查 URI 段