蚂蚁:通过propertyregex获得多个匹配项 [英] Ant: get multiple matches with propertyregex

查看:86
本文介绍了蚂蚁:通过propertyregex获得多个匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML文件中有以下(示例)行:

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

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

还有这个蚂蚁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}" />

结果就是

ABC

但是我想获得所有比赛.我怎么能得到

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

ABC
ABCD
ABCE

结果?

推荐答案

不确定propertyregex问题,但这可以解决问题(不使用ant-contrib):

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>

这篇关于蚂蚁:通过propertyregex获得多个匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆