1

スプリングの構成は次のとおりです。

<bean id="wrapInMarginalMarkup" class="com.a.ChangeContentAction">
        <property name="regEx">
            <bean class="java.util.regex.Pattern" factory-method="compile">
                <constructor-arg value="(.*)(&lt;m&gt;)(.*)(&lt;xm&gt;)(.*)" />
            </bean>
        </property>
        <property name="replaceExpression" value="$1&lt;marginal\.markup&gt;$3&lt;/marginal\.markup&gt;$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,,&lt;m&gt;Surface Transportation Extension Act of 2012.,&lt;xm&gt;"

ここでマークアップを実際に置き換えているようには見えませんが、何が問題なのですか?

出力文字列を次のようにしたい:

"Be it enacted by the Senate and House of Representatives of the United States of America in Congress assembled,,&lt;marginal.markup&gt;Surface Transportation Extension Act of 2012.,&lt;/marginal.markup&gt;"
4

2 に答える 2