Search code examples
javaregexant

ANT attribute in regex pattern


I'm writing an utility macro which involves checking whether a comma-separated list list contains or does not a particular value value.

<macrodef name="csvcontains">
    <attribute name="value"/>
    <attribute name="list"/>
    <attribute name="casesensitive" default="false"/>
    <sequential>
    <condition property="matched" else="false">
        <matches string="@{list}" pattern="TODO" casesensitive="@{casesensitive}"/>
    </condition>
    </sequential>
</macrodef>

I cannot get the pattern right, because I'm not sure of how to escape @{value} (and to match a comma-separated pattern).

How to build the pattern?


Solution

  • Have you tried? It is my understanding that ant resolves all variables in a first step, so you probably don't have to escape @{value}