I'm trying to add log4j to a legacy software using eclipse search/replace.
The idea is to find all class declarations and replace them by, the declaration itself plus the definition of the logger in the next line.
search
".*class ([A-Z][a-z]+).*\{"
replace:
"final static Logger log = Logger.getLogger($1.class);"
How can I prepend the matched pattern (the class definition) to the replace string?
I think you need this:
search:
(.*class ([A-Z][a-z]+).*\{)
replace:
$1\Rfinal static Logger log = Logger.getLogger($2.class);
You can always capture the whole thing and put it in. The inner capture group lives in a second backreference.
Find:
(.*class ([A-Z][a-z]+).*\{)
Replace with:
$1 final static Logger log = Logger.getLogger($2.class);
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