What is the match group syntax in Eclipse's se

2019-03-24 19:36发布

问题:

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

On vi I:

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

And lines like:

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.

回答1:

Use $1 instead of \1

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

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:



回答2:

In the Find Field: log(.*)

Int the Replace With Field: log$1 debug