Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse search and replace with wildcard

I am trying to remove all occurances of id="someId" where someId is different in every case. I have tried to use this syntax: (id="\w+\"\(\)) because it's used in similar situations by other posters. But I don't understand the syntax and of course it doesn't work.

Could someone tell me why this syntax is incorrect and maybe point me to a resource that explains the syntax?

like image 944
travega Avatar asked Oct 08 '12 21:10

travega


People also ask

How do I search for multiple keywords in eclipse?

Solution. Use the built-in Eclipse Search dialog. The Search menu contains multiple items (Search→ Search, Search→ File, Search→ Help, and Search→ Java), but all of them open the same dialog.

How do I search for a regular expression in Eclipse?

In Eclipse use the Ctrl + H shortcut to open the Search dialog. Select the File Search tab and check the Regular expression flag before entering your regular expression. You can also specify the file type and the scope for the search and replace operation.


1 Answers

Check "Regular expressions" check box. The expression is

id\s*=\s*"[^"]+"

\s* means space, * means zero or more

[^"] means anything but quote, + means one or more

To capture the string use "([^"]+)" and $1 in the replace with field.

More info at http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

like image 170
Aubin Avatar answered Sep 23 '22 01:09

Aubin