Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ newline in regex

Suppose you have this file:

x a b c x x a b c x x 

and you want to find the sequence abc (and select the whole 3 lines) with Notepad++ . How to express the newline in regex, please?

like image 769
theSpyCry Avatar asked Dec 09 '10 13:12

theSpyCry


People also ask

How do you represent a new line in regex?

"\n" matches a newline character.

How do I add a line break in regex?

\n Escaped character. Matches a LINE FEED character (char code 10). \s Whitespace. Matches any whitespace character (spaces, tabs, line breaks).

How do you match a new line in Notepad++?

In Notepad++ press Ctr+H to open the “Find and Replace” window. Under Search Mode: choose “Regular expression” and then check the “matches newline” checkbox.

Can I use regex 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.


1 Answers

Notepad++ can do that comfortably, you don't even need regexes

In the find dialogue box look in the bottom left and switch your search mode to Extended which allows \n etc.

As odds on you're working on a file in windows format you'll be looking for \r\n (carriage return, newline)

a\r\nb\r\nc 

Will find the pattern over three lines

like image 58
Robb Avatar answered Sep 23 '22 04:09

Robb