使用 Notepad++ 正则表达式搜索替换整个匹配值并替换 [英] Replace with whole match value using Notepad++ regex search and replace

查看:80
本文介绍了使用 Notepad++ 正则表达式搜索替换整个匹配值并替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下表达式:

I am using the following expression:

查找内容:[0-9]

但是如果我想为所有数字添加特定的 sup 标签,我应该在 Replace with 字段中写什么?

But what should I write in Replace with field if I want to add specific sup tag to all the digits?

提前致谢!

推荐答案

替换即可

<sup>$0</sup>

<sup>$&</sup>

注意 $0/${0}/$&,甚至 $MATCH${^MATCH} backrefrence 插入整个匹配.

Note that the $0 / ${0} / $&, or even $MATCH and ${^MATCH} backrefrence inserts the whole match.

请参阅替换 部分:

See the Substitutions section:

$&$MATCH${^MATCH}
    整个匹配的文本.

$&, $MATCH, ${^MATCH}
       The whole matched text.

$n, ${n}, \n
     返回与编号为 n 的子表达式匹配的内容.不允许出现负指数.

$n, ${n}, \n
      Returns what matched the subexpression numbered n. Negative indices are not alowed.

请注意,匹配值通常作为组 0 存储在匹配对象中.

Note that a match value is usually stored as Group 0 inside a match object.

但是\0 到目前为止不起作用(Notepad++ v.6.9),看起来它被视为 NUL 字符并截断替换模式在它所在的位置.

However, \0 as of now does not work (Notepad++ v.6.9), it looks like it is treated as a NUL character and truncates the replacement pattern right at the location where it is located.

这篇关于使用 Notepad++ 正则表达式搜索替换整个匹配值并替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆