Ant Contrib propertyregex通过附加字符返回所有匹配项
我的ant构建可以接收以下任何一个输入(典型的类路径) 我想通过RegEx将上述条目转换为以下内容:Ant Contrib propertyregex通过附加字符返回所有匹配项,regex,ant,ant-contrib,Regex,Ant,Ant Contrib,我的ant构建可以接收以下任何一个输入(典型的类路径) 我想通过RegEx将上述条目转换为以下内容: -ID:\Source\Dir1 -ID:\Source\Dir1 -ID:\Source\Dir1 -ID:\Source\Dir2 -I/Source/Dir1 -I/Source/Dir1 -I/Source/Dir1 -I/Source/Dir2 到目前为止,我已经在我的蚂蚁的追随者 <propertyregex property="Example1-Result" input=
-ID:\Source\Dir1
-ID:\Source\Dir1
-ID:\Source\Dir1 -ID:\Source\Dir2
-I/Source/Dir1
-I/Source/Dir1
-I/Source/Dir1 -I/Source/Dir2
到目前为止,我已经在我的蚂蚁的追随者
<propertyregex property="Example1-Result" input="${example}" regexp="[^${path.separator}^$]+(?:)*" replace="-I\0 " global="true"/>
只是想摆脱和:从结果来看。我会分两次做,以使这一点更清楚。第一句话是你的:
<propertyregex property="Example1-Result" input="${example}"
regexp="[^${path.separator}^$]+(?:)*" replace="-I\0 " global="true"/>
第二种是简单的搜索和替换,以删除保留的冒号或分号:
<propertyregex property="Example1-Result" input="${Example1-Result}"
regexp="[:;]" replace=" " global="true" override="true"/>
这种方法假设普通文件名中没有分号或冒号,但这似乎不太可能。为什么不第二次在propertyregex中运行它来去掉这两个字符呢?您是否希望它们出现在数据中的其他位置?不,但第二个表达式是什么?只是想移除;并且:创建了一个展示这种方法的帖子。请注意它是如何使用重写来重新使用相同的属性的。谢谢…这是正确的。我还得到了另一个非常简单的解决方案。见下文<代码>第一条语句将替换
;和:
到“-I”,第二条语句只为类路径中的第一个条目添加-I
<propertyregex property="Example1-Result" input="${example}"
regexp="[^${path.separator}^$]+(?:)*" replace="-I\0 " global="true"/>
<propertyregex property="Example1-Result" input="${Example1-Result}"
regexp="[:;]" replace=" " global="true" override="true"/>