CTRL + space in the textboxes gives your all kinds of suggestions for regular expression writing.
Find
Replace
Be sure to check out the \c regular expression operator, which I think are specific to Eclipse.
It saves a lot of work in replacing the same word in upper-case, lower-case, and CamelCase variants.
For example, if the original text is:
Someobject Someobject Someobject;
Then doing a "Replace all" replacing
Someobject
with
\cAnotherobject
Would get you:
Anotherobject anotherobject = Anotherobject;
Https://dzone.com/articles/using-regular-expressions
I had an old method with hundreds of lines doing calling a getattribute ("X") and casting the result to a string.
(string) Object1.getattribute ("X") (string) Object2.getattribute (" Y " ) (String) Objectn.getattribute ("Z")
I had to change them any to use a new method, which checks if the attribute is null. So the new line would is
Getsafestringattribute (Object1,"X") Getsafestringattribute (object2," Y") Getsafestringattribute (objectn,"Z")
With the simple regEx you can do a replace all!
Find :
\ (string\) (. +) \.getattribute\ ("(. +)" \)
Replace: Getsafestringattribute ($ "$")
The first (. +) would match the Objectx part while the second would match the attribute name.
The best thing is the If you select some text and
Type CTRL + F (if the Regular Expressions checkbox is ticked)
You string in the find would be a already escaped from characters like ' (', ') ' etc!
Eclipse Regular expression Lookup and substitution