Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I match an entire line in Notepad++ for search/replace?

I'd like to do a bulk line-by-line replace on a file within Notepad++ like so:

This is my line of text that I would like to replace

to

"This is my line of text that I would like to replace" +

I tried the following:

Find: ^$ Replace: "\1" +

Find: ^()$ Replace: "\1" +

Find: (^$) Replace: "\1" +

Any hints? Thanks in advance!

like image 307
John Avatar asked Nov 08 '11 15:11

John


People also ask

How do you replace an entire line in Notepad++?

To replace text in Notepad++, follow the steps below. Open the text file in Notepad++. In the top menu bar, click Search and select Replace. In the Replace window, on the Replace tab, enter the text you want to find and the text you want to use as a replacement.

How do I Find and replace a pattern in Notepad++?

Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.

How do I search for a pattern in Notepad++?

Ctrl+F will bring up the search window. Click on the Find in Files tab. Note: This tab has a specific shortcut – Ctrl+Shift+F – and can be found in the Search menu.


2 Answers

Try to search for ^(.*)$ and replace with "\1" +

The difference between this and your's is that this one captures all characters between the starting and ending of the string. Your regexes simply tries to capture nothing.

like image 194
Marcus Avatar answered Oct 08 '22 01:10

Marcus


Try this:

Find: ^(.*?)$

Replace: "\1" +
like image 33
Dennis Avatar answered Oct 08 '22 01:10

Dennis