There’s a properties language bundle file:
label.username=Username:
label.tooltip_html=Please enter your username.</center></html>
label.password=Password:
label.tooltip_html=Please enter your password.</center></html>
How to match all lines that have both “_html” and “</center></html>” in that order and replace them with the same line except the ending “</center></html>”. For example, line:
label.tooltip_html=Please enter your username.</center></html>
should become:
label.tooltip_html=Please enter your username.
Note: I would like to do this replacement using an IDE (IntelliJ IDEA, Eclipse, NetBeans…)
Since you clarified that this regex is to be used in the IDE, I tested this in Eclipse and it works:
Make sure you turn on the Regular expressions switch in the Find/Replace dialog. This will match any string that contains
_html.*(where the.*greedily matches any string not containing newlines), followed by</center></html>. It uses(…)brackets to capture what was matched into group 1, and$1in the replacement substitutes in what group 1 captured.This effectively removes
</center></html>if that string is preceded by_htmlin that line.If there can be multiple
</center></html>in a line, and they are all to be removed if there’s a_html_to their left, then the regex will be more complicated, but it can be done in one regex with\Gcontinuing anchor if absolutely need be.Variations
Speaking more generally, you can also match things like this:
This now creates 2 capturing groups. You can match strings with this pattern and replace with
$1$2, and it will effectively deletethis part only, but only if it’s preceded bydeleteand followed byplease. These subpatterns can be more complicated, of course.