Reputation: 14551
Using the Eclipse Search function CTRL-H
, what would be a regex to replace all occurrences of <spring:message />
tags like:
<label>
<spring:message code="name" />
</label>
<h1><spring:message code="title" /></h1>
with:
<label th:text="#{name}"></label>
<h1 th:text="#{title}"></h1>
Edit
Nice would be if the regex would also handle replacement of:
<label class="lalala"><spring:message code="name" /></label>
Upvotes: 0
Views: 324
Reputation: 10466
You can use this generic one:
<([^>]+)>\s*<\s*spring:message\s+code="([^"]*)"[^<]+<\/\1>
and replace by:
<\1 th:text="#\{\2\}"><\/\1>
You may have to escape the backslaseh for your IDE like this:
regex:
(?s)<([^>]+)>\\s*<\\s*spring:message\\s+code=\"([^\"]*)\"[^<]+<\\/\\1>
subst
<\\1 th:text=\"#\\{\\2\\}\"><\\/\\1>
Upvotes: 3
Reputation: 15008
This should work
(?s)<label>[^<]*<spring:message code="([^"]*)" */>[^<]*</label>
->
<label th:text="#{$1}"></label>
and
<h1><spring:message code="([^"]*)" /></h1>
->
<h1 th:text="#{$1}"></h1>
(The (?s) is there to allow multiline matches: multiline search replace with regexp in eclipse)
Upvotes: 2