Mohan Seth
Mohan Seth

Reputation: 769

regular expression to find string

Can someone help me with the regular expression to find and replace a particular code inside a large project in eclipse I am working on:

Eg: I want to select all code that contains following "new ArrayList<some value..>();"

Like:

new ArrayList<Content>();

new ArrayList<User>();

new ArrayList<Content_User_Mapping>();

and replace with:

new ArrayList<Content>(0);

new ArrayList<User>(0);

new ArrayList<Content_User_Mapping>(0);

Any help would be much appreciated, thanks.

Upvotes: 1

Views: 35

Answers (1)

aioobe
aioobe

Reputation: 421030

Try replacing ArrayList<(.*)>\(\) with ArrayList<$1>(0).

What to keep in mind when dealing with the search and replace dialog:

  • The find-field (when using regular expressions) expects a regular expression so
    • ( and ) are special and needs to be escaped
    • (...) represents a group
  • The replace field does not have special treatement for ( and ), but allows you to refer to the captured groups by $n.

Upvotes: 1

Related Questions