[英]How to delete multiple lines with different text in between using RegEx in Notepad++?
What I need to do is to delete everything that ends with desktop.ini
and begins with Library
with varying text in between.我需要做的是删除所有以desktop.ini
结尾并以Library
开头且中间有不同文本的内容。
In my list, it looks like this:在我的列表中,它看起来像这样:
Library\aaaa\desktop.ini
Library\bbbb\1111\desktop.ini
Library\bbbb\line-I-dont-want-to-delete
Library\cccc\222\CCCC\desktop.ini
Library\dddd\3333\D\desktop.ini
After using the Replace feature, all that should be left is:使用替换功能后,剩下的就是:
Library\bbbb\line-I dont-want-to-delete
. Library\bbbb\line-I dont-want-to-delete
。
I'm really terrible with RegEx, but what I need is something like this:我对 RegEx 真的很糟糕,但我需要的是这样的:
^Library\$[(AZ)?]\desktop.ini
Apologies if that's all I have, but thanks in advance for helping me with this!抱歉,如果我只有这些,但在此先感谢您帮助我!
You can use您可以使用
Find What: ^Library\\(?:.*\\)?desktop\.ini$\R?
Replace With: <empty>
Details :详情:
^
- start of string ^
- 字符串的开始Library\\
- Library\
string Library\\
- Library\
字符串(?:.*\\)?
- an optional non-capturing group matching zero or more chars other than line break chars as many as possible and then a \
char - 一个可选的非捕获组匹配零个或多个除换行字符以外的字符尽可能多,然后是一个\
字符desktop\.ini
- a desktop.ini
string desktop\.ini
- desktop.ini
字符串$
- end of line $
- 行尾\R?
- an optional line break char (sequence). - 一个可选的换行符字符(序列)。See the demo below:请参阅下面的演示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.