子字符串替换正则表达式 Notepad++ [英] substring replacement regex Notepad++

查看:62
本文介绍了子字符串替换正则表达式 Notepad++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Notepad++ 来替换一些文本.我是使用正则表达式的新手,但遇到了这个问题:

I am trying to use Notepad++ to substitute some text. I am new to using regex and I am having trouble with this:

  • [characters]替换[CHARACTERS]形式的任何模式,例如[SOMEDATA] 变成 (somedata).
  • Replace any pattern in the form of [CHARACTERS] with [characters], e.g. [SOMEDATA] becomes (somedata).

这就是我所拥有的,有什么建议吗?

This is what I have, any suggestions?

s/^#+$/#

它不起作用!

推荐答案

确保将 Notepad++ 更新到最新版本 - 他们在最近的更新中大大改进了正则表达式引擎.

Make sure you update Notepad++ to the latest version - they improved the regex engine considerably in recent updates.

如果您查看 Notepad++ 的正则表达式文档,你会看到它实际上支持控制序列来改变替换中的大小写.

If you have a look at the regex documentation of Notepad++, you'll see that it actually supports control sequences to change the capitalization in the substitution.

我不太确定您是否也想匹配那些方括号.如果您只想将匹配项转换为小写,那么您可以在 Replace with: 部分使用它:

I am not quite sure whether you want to match those square brackets as well. If all you want is to turn your match into lower case, then you can use this in the Replace with: part:

\L$0

\L 将所有内容转为小写,直到遇到 \E,而 $0 指的是您的整个匹配项,以便您可以写回去.

The \L turns everything lower case until an \E is encountered, and the $0 refers to your entire match, so that you can write it back.

这篇关于子字符串替换正则表达式 Notepad++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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