Ant: получить несколько совпадений с помощью propertyregex - PullRequest
2 голосов
/ 30 марта 2012

У меня есть эти (примерные) строки в HTML-файле:

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

Но я бы хотел получить все совпадения. Как я могу получить

ABC
ABCD
ABCE

как результат?

1 Ответ

0 голосов
/ 30 марта 2012

Не уверен насчет проблемы propertyregex, но это работает (без 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...