Matthew D. Scholefield
Matthew D. Scholefield

Reputation: 3345

How to search and replace phrase in eclipse/regex

I am attempting to find and replace in eclipse the phrase

doSomething(*, with

doSomething(*)

(Where * is a wildcard)

I've tried both ctrl+f and ctrl+h. When I use a wildcard, it will find the phrase, but then when it is replaced, it will be replaced with literally, the asterisk, not the phrase that was inside of it. Is there a method to do so (maybe with regular expressions?). If there is not a way in eclipse, is there any software that will?

Upvotes: 2

Views: 1847

Answers (2)

hwnd
hwnd

Reputation: 70750

You need to enable the Regular expressions checkbox when you hit CTRL + F.

Find: (doSomething\([^,]+),
Replace: $1)

Use $n in replace where n is the nth occurrence of a capture group ( )

Upvotes: 3

Kent
Kent

Reputation: 195249

ctrl-f and checked the Regular expressions option,

Find: (doSomething\([^,]*),

Replace with: \1)

Upvotes: 2

Related Questions