I'm using Notepad++ and basically I want to find all blank lines that don't contain text using Notepad++ regex. I know that there is a simpler way of doing this by using 'textfx,' but I'm looking for an expression to do this. Here is an example below with the symbols shown.
< ?php **CRLF**
**CRLF** *<- REMOVE THIS*
$xxx = $_POST['xxx'];**CRLF**
$xxx = $_POST['xxx'];**CRLF**
$xxx = $_POST['xxx'];**CRLF**
**CRLF** *<- REMOVE THIS*
**CRLF** *<- REMOVE THIS*
if ($xxx)**CRLF**
{**CRLF**
Open Notepad++ and the file you want to edit. In the file menu, click Search and then Replace. In the Replace box, in the Find what section, type ^\r\n (five characters: caret, backslash 'r', and backslash 'n'). Leave the Replace with section blank unless you want to replace a blank line with other text.
You can use \r\n to find blank lines from text files made within Windows, \r for Mac and \n for Linux.
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.
I just did find ^\r\n and replace with nothing
Not a regular expression, but Notepad++ 6.3.2 has a number of ways of removing blank lines without using a regular expression.
Menu => Edit => Line operations => Remove empty lines
Menu => Edit => Line operations => Remove empty lines (containing blank characters)
Menu => TextFx => TextFx Edit => Delete blank lines
Menu => TextFx => TextFx Edit => Delete surplus blank lines
The two TextFx methods only delete empty lines, but they can be preceded with either of:
Menu => Edit => Blank operations => Trim trailing spaces
Menu => TextFx => vTextFx Edit** => Trim trailing spaces
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With