正则匹配
<propertyregex property="pack.name"
input="package.1.name"
regexp="(package)\.\d\.(name)"
select="\1.DEF.\2"
casesensitive="false" />
<echo>***************${pack.name}</echo>
</target>
解压
<target name="unzip_file1">
<propertyregex property="zipName"
input="${domain_package}"
regexp="(\\)[\S]+(.zip)$"
select="\1\2"
casesensitive="false" />
<unzip src="${domain_package}" dest="output/zip/${zipName}" encoding="GBK"/>
</target>
在引入for、var使用时需要首先在ant的build lib中引入ant-contrib.jar
且需要在build.xml中优先加载其配置:
<!--配置ant相关延展命令。例如var、for-->
<target name="config" >
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${ant.libs}/ant-contrib.jar" />
</classpath>
</taskdef>
</target>
正则匹配参照:Ant: propertyregex