Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the match group syntax in Eclipse's search and replace

What's the syntax to perform a search/replace on Eclipse and use "match groups" (is that what it's called?)

On vi I do the following:

%s/log\(.*\)/log \1 debug/g 

And lines like this one:

log "Message" 

are replaced with:

log "Message" debug

What's the correct syntax for eclipse in the search/replace dialog box (beside checking up "Regular expressions")

Thanks.

like image 724
OscarRyz Avatar asked Jul 07 '09 23:07

OscarRyz


2 Answers

Use $1 instead of \1

For the /g global replace flag, use the Replace All button:

eclipse find/replace dialog
(source: bpsite.net)

Note: The above is the Find/Replace dialog for a single file, comes up for Ctrl-F

For working across multiple files, default shortcut is Ctrl-H, and the dialogs are a bit different:

eclipse search & replace dialogs

like image 53
Peter Boughton Avatar answered Sep 21 '22 16:09

Peter Boughton


In the Find Field: log(.*)

Int the Replace With Field: log$1 debug

like image 36
AdamC Avatar answered Sep 21 '22 16:09

AdamC