スプリングの構成は次のとおりです。
<bean id="wrapInMarginalMarkup" class="com.a.ChangeContentAction">
<property name="regEx">
<bean class="java.util.regex.Pattern" factory-method="compile">
<constructor-arg value="(.*)(<m>)(.*)(<xm>)(.*)" />
</bean>
</property>
<property name="replaceExpression" value="$1<marginal\.markup>$3</marginal\.markup>$5" />
</bean>
このクラスは、次のような Java のパラメーターを受け入れます。
private Pattern regEx;
private String replaceExpression;
/**
* {@inheritDoc}
*/
@Override
public int execute(final BuilderContext context, final Paragraph paragraph)
{
String content = paragraph.getContent();
paragraph.setContent(regEx.matcher(content).replaceAll(replaceExpression));
}
これは、パターンで一致する文字列がどのように見えるかです:
"Be it enacted by the Senate and House of Representatives of the United States of America in Congress assembled,,<m>Surface Transportation Extension Act of 2012.,<xm>"
ここでマークアップを実際に置き換えているようには見えませんが、何が問題なのですか?
出力文字列を次のようにしたい:
"Be it enacted by the Senate and House of Representatives of the United States of America in Congress assembled,,<marginal.markup>Surface Transportation Extension Act of 2012.,</marginal.markup>"