我在 Notepad++ 中有以下内容
edit "apple"
set price 10
edit "pear"
set price 12
edit "orange"
set price 10
edit "cherry"
edit "plum"
edit "grapes"
set price 10
edit "peach"
edit "mango"
set price 10
我想删除不包含价格的行;请问我该怎么做?
答案1
那是你要的吗?
- Ctrl+H
- 找什么:
^edit.+\R(?!^\h+set price)
- 用。。。来代替:
LEAVE EMPTY
- 查看 相符
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
^ # beginning of line
edit # literally
.+ # 1 or more any character but newline
\R # any kind of linebreak (i.e. \r, \n, \r\n)
(?! # negative lookahead, make we haven't after:
^ # beginning of line
\h+ # 1 or more horizontal spaces
set price # literally
) # end lookahead
截图(之前):
截图(之后):