Multiline Regular Expression search and replace!

Scott picture Scott · Sep 17, 2009 · Viewed 51.7k times · Source

I've hit a wall. Does anybody know a good text editor that has search and replace like Notepad++ but can also do multi-line regex search and replace? Basically, I am trying to find something that can match a regex like:

search oldlog\(.*\n\s+([\r\n.]*)\);
replace newlog\(\1\)

Any ideas?

Answer

Mark Salisbury picture Mark Salisbury · Jun 15, 2012

Notepad++ can now handle multi line regular expressions (just update to the latest version - feature was introduced around March '12).

I needed to remove all onmouseout and onmouseover statements from an HTML document and I needed to create a non-greedy multi line match.

onmouseover=.?\s*".*?"

Make sure you check the:

[ ] . matches newline
checkbox if you want to use the multi line match capability.