How to use RegExp replace in Eclipse

By Andrea Ercolino, 2009-10-01 12:22:43

Here is a quick tip for when you want to replace some text in your code.

Say that you have many HTML attributes like name="email" and you want to replace them with name="<?= $field['email']['name']; ?>". Then you must search for name="(\w+?)" and replace with name="<?= \$field['\1']['name'] ?>". Note that you need to escape the $ with a backslash for Eclipse to do its work. If you omit it, Eclipse will simply not work and not complain.

2 Responses to “How to use RegExp replace in Eclipse”

  1. I found still very short regular expression.

    href=”(.*?)”

    This does the same as done by

    href=”http:\/\//?(\w+.)+”

  2. While I wanted to capture some hyperlinks I found this regular expression useful, hope this help some people who are trying to capture hyperlinks in search.

    Regular Expression is :

    href=”http:\/\//?(\w+.)+”

    I am sure that could have been done in easy way, but that was all I knew.

    with best regards,
    Samundra

Leave a Reply

Panorama Theme by Themocracy