如何使用通配符Regex Notepad ++

问题描述 投票:0回答:2

您好我是Notepad ++替换选项的正则表达式中的新功能我有很多以文件开头的文件

#include <right/someheader.h>

我需要将它们转换为

#include "someheader.h"

没有丢失someheader.h我尝试使用此替换方法:

#include <right/.*>  

但它不会得到someheader.h的价值,它会简单地替换它:

#include ".*"

是否可以使用正则表达式工作?在Notepad ++我已经看到了这个:qazxsw poop但是我不明白如何应用我的需求可以有人帮忙吗?谢谢

regex notepad
2个回答
1
投票

替换正则表达式找到的匹配项:

https://superuser.com/questions/637476/using-wildcard-search-replace-in-notepad

<[^\/]*\/([^>]*)>

"$1"

说明:

  • Click for Demo - 匹配<
  • < - 匹配除了[^\/]*之外的任何字符的0+次出现
  • / - 匹配\/
  • / - 匹配除([^>]*)之外的任何字符的0+次出现并将其存储在第1组中
  • > - 匹配>

更换前:

>

更换后:

enter image description here


0
投票

找到你要找的东西的正则表达式是这样的:

enter image description here

你想要用以下代替它:

#include <right\/(.*)>

括号内的任何内容都存储在变量中,可以使用#include "\1" \1等引用。因此,这会在“right /”之后抓取任何内容,并将其存储在变量\2中。

© www.soinside.com 2019 - 2024. All rights reserved.