Ant: get multiple matches with propertyregex

2019-07-19 11:05发布

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?

标签: ant
1条回答
够拽才男人
2楼-- · 2019-07-19 11:30

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>
查看更多
登录 后发表回答