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?
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.
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.
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
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