The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Regular Expression

I'm rusty on REs. We have a large java code base littered with System.outs. I'd like to replace these with log4j loggers.

Simple enough to do a global find/replace for System.out.println to or something. However, I'd like to add a small amount of granularity by doing logger.errors on any System.out that is inside a catch statement, and use for everything else.

Using eclipse we can do searches via regexs but just wondering what type of regex could detect the System.outs inside the catch statements.

Any ideas?
Col Send private email
Tuesday, March 06, 2007
There is a lot of info and tutorials on

A very good resource that I have used a lot.
Read the tutorial and you should be up and running very quickly!
Parisian Developer (still looking)
Wednesday, March 07, 2007
Download a 30-day free trial of IntelliJ IDEA from and use its structural search and replace feature. This is great - it's a search and replace that's aware of the structure of Java code.

You can use a search template something like:

try {
} catch($ExceptionType$ $ExceptionDcl$) {

I've used it in the past for things like automatically converting empty catch blocks into catch blocks containing a wrap with RuntimeException and rethrow. It does take a bit of fiddling around to make it do the right thing, though, but will be much easier than a regex.
Inigo Send private email
Wednesday, March 07, 2007
Search for "Regular Expression Coach."  It's a program that lets you interactively try various REs.
James Send private email
Friday, March 09, 2007
either read MRE or fail at REs forever.

+1 to james. re coach is a very good tool.

Friday, March 23, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz