views:

3944

answers:

11

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?

+1  A: 
Donut
A: 

You could use Visual Studio. Download Express for free if you don't have a copy.

VS's regex is non-standard, so you'd have to use \n:b+[\r\n] instead.

Shane Cusson
A: 

EditPlus does a good job at search/replace using regex (including multiline)

Philippe Leybaert
+2  A: 
DVK
An editor that costs 50 bucks is hardly a replacement for Notepad++. Yeah, it has lots of stuff like FTP client or CSS validation, but what's good in it if I don't need it?
Malcolm
@Malcolm - Personally it was worth it for me. Worth it for a LOT of people seeing how the guy(s) making it are still in business :)Also, the OP never asked for a "free replacement". He asked for which editor CAN replace which has a certain feature.
DVK
I should've said, equivalent replacement. If you have spare 50 dollars, sure, this would be a good investment, but what if I already have everything I need, except for the multiline regex? And also personally I'm not a fan of "do everything with one app", especially in commercial programs, because you pay for everything and use at most half of the featureset.I see you point, though, that's why I didn't vote down or something. It's just my opinion.
Malcolm
Having actually been forced to use Notepad++ (a new hire can't install UltraEdit yet due to company policy and I was helping her), I must say it lacks WAY too many things I consider basic and incredibly useful-to-necessary in a programming editor/IDE. Sometimes free as in beer is good. Sometimes you get what you pay for :)
DVK
Mind you, I know some peoples requirements find N++ perfectgly fine. Hell, having programmed in EDLIN back when, I at one time would have found N++ top be manna.
DVK
Sorry to spoil the fun, but UE has some serious defects in its regex engine especially when multi-line strings are concerned. For example, lookbehind doesn't work across newlines.
Tim Pietzcker
@Tim - didn't know that... will remember in the future... do you have a resource with full list of defects?... BTW, now I'm curious... what'd be the practical use of a lookbehind in PCRE in an editor? :)
DVK
Tim Pietzcker
I should also mention that I find UE to be a terrific editor. Just the regex engine is not quite as good as I'd like it to be.
Tim Pietzcker
A: 
Dave Jarvis
+2  A: 

EditPad Pro has better regex capabilities than any other editor I've ever used.

Also, I suspect you have an error in your regex — [\r\n.] will match only carriage returns, newlines, and full stops. If you're trying to match any character (i.e. "dot operator plus CR and LF), try [\s\S] instead.

Ben Blank
+1 for EPP - nobody does it better.
Tim Pietzcker
A: 

The latest version of UltraEdit has multiline find and replace w/ regex support.

Or if you're OK with using a more specialized regular expression tool for this, there's Regex Hero. It has the side benefit of being able to do everything on the fly. In other words, you don't have to click a button to test your regular expression because it's automatically tested after every keypress.

Personally, I'd use UltraEdit if I'm looking to replace text in multiple files. That way I can just select the files to replace as a batch and click Replace. But if I'm working with a single text file and I'm in need of writing a more complex regular expression then I'd paste it into Regex Hero and work with it there. That's because Regex Hero can save time when you see everything happen in real-time.

Steve Wortham
Actually UltraEdit has had multiline find/replace with Regex for many years. I'm running 8.0 (and just found out I'm 7 releases behind... time to make a petty cash request) and do multiline regex all the time.
jmucchiello
Steve Wortham
A: 

The Zeus editor can do multi-line search and replace.

jussij
A: 

PilotEdit is the perfect tool to do multiline regular expression search and replace. www.pilotedit.com

Dracoder
+1  A: 

I use Eclipse, which is free and that you may already have if you are a developer. '\R' acts as platform independent line delimiter. Here is an example of multi-line search:

search:

\bibitem.(\R.)?\R?{([^{])}$\R^([^\].[^}]$\R.$\R.)

and replace:

\defcitealias{$2}{$3}

Vladtn
A: 

I'm pretty sure Notepad++ can do that now via the TextFX plugin (which is included by default). Hit Control-R in Notepad++ and have a play.

Michael