Ant: get multiple matches with propertyregex

时光毁灭记忆、已成空白 提交于 2019-12-24 02:24:14

问题


I have these (sample) lines in a HTML-file:

test.ABC.test
test.ABCD.test
test.ABCE.test

And this Ant propertyregex:

<loadfile property="getRecords" srcFile="./index.html"/>
<propertyregex property="record" input="${getRecords}" regexp="test\.([^\.]*)\.test" select="\1" casesensitive="true" override="true" global="true" />
<echo message="${record}" />

The result is just

ABC

But I'd like to get all matches. How can I get

ABC
ABCD
ABCE

as result?


回答1:


Not sure about the propertyregex problem, but this works (without ant-contrib):

<target name="test">
    <loadfile property="record" srcFile="./index.html">
        <filterchain>
            <tokenfilter>
                <containsregex pattern=".*test\.([^\.]*)\.test.*" replace="\1"/>
            </tokenfilter>
        </filterchain>
    </loadfile>
    <echo message="${record}" />
</target>


来源:https://stackoverflow.com/questions/9939485/ant-get-multiple-matches-with-propertyregex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!