Eclipse Find replacement Smart tricks usage

Source: Internet
Author: User

When using eclipse, finding replacements may be a tool we often use, but most of them simply look for replacements for simple word text (such as finding replacement warnings), but in complex situations, most people may manually change.

For example:

/* */Public     class configuration/* */{/*/   Private list<context> contexts;/*     *   / Private list<string> classpathentries;/*     */* *     * public   Configuration (     )  /*/*/* * * *     this.contexts = new ArrayList ();/* */     this.classpathentries = new ArrayList ();/*     *   }/*     *//*     *   /public void Addclasspathentry (String entry) {/* *  * *     This.classPathEntries.add (entry);/* *     */   }/*     */}</context>

When we encounter the above code, we can easily replace the "/* * * * * * * * * * * * * * * *, but cannot replace the comment like"/* 41 * * ".


In fact, Eclipse's find-and-replace tool supports regular Expressions ,


Tick "Regular expressions", that is, switch to "regular expression" mode.

In the Find Input box, type:/\* (\s|\w) * \*/

You can then replace all of the "/* * * * * * * * * * * *and the comments with the number in the middle.


Again, for example, match the string with the <title> start </title> end:<title>.*?</title>

Match HTML or XML tags:< (\s+) (((\s[^<>]*)?\/>) | ( \s[^>]*)?>[\s\s]*?<\/\1\s*>)


We know that after the lookup substitution supports regular expressions, many query matches can be implemented, but it is important to be cautious about fuzzy matching, or the wrong substitution will cause problems.

Eclipse Find and replace smart tricks usage

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.