Eclipse Regular expression Lookup and substitution

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.