Notepad++ Regular expression find and delete a lin

2019-03-08 04:45发布

I am trying to find and delete a line using Notepad++

I need to find lines in this file (UNIX Format) that match the string '#RedirectMatch Permanent' and delete that line.

Does anyone know how to do this using Notepad++ Find and Replace?

Thanks and Kind Regards,

5条回答
女痞
2楼-- · 2019-03-08 05:34

Provide the following in the search dialog:

Find What: ^$\r\n
Replace With: (Leave it empty)

Click Replace All

查看更多
可以哭但决不认输i
3楼-- · 2019-03-08 05:34

Using the "Replace all" functionality, you can delete a line directly by ending your pattern with:

  • If your file have linux (LF) line ending : $\n?
  • If your file have windows (CRLF) line ending : $(\r\n)?

For instance, in your case :

.*#RedirectMatch Permanent.*$\n?
查看更多
时光不老,我们不散
4楼-- · 2019-03-08 05:37

If it supports standard regex...

find:
^.*#RedirectMatch Permanent.*$

replace:

Replace with nothing.

查看更多
forever°为你锁心
5楼-- · 2019-03-08 05:38

Step 1

  • Search -> Find -> (goto Tab) Mark
  • Find what: ^Session.*$
  • Enable the checkbox Bookmark line
  • Enable the checkbox Regular expression (under Search Mode)
  • Click Mark All (this will find the regex and highlights all the lines and bookmark them)

Step 2

  • Search -> Bookmark -> Remove Bookmarked Lines
查看更多
再贱就再见
6楼-- · 2019-03-08 05:41

Combining the best from all the answers

enter image description here

查看更多
登录 后发表回答