【发布时间】:2014-10-03 23:17:31
【问题描述】:
我的 ant build 可以接收以下任何一种输入(典型的类路径);
D:\Source\Dir1
D:\Source\Dir1;
D:\Source\Dir1;D:\Source\Dir2
/Source/Dir1
/Source/Dir1:
/Source/Dir1:/Source/Dir2
我想通过 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
到目前为止,我的 ANT 中有以下内容;
<propertyregex property="Example1-Result" input="${example}" regexp="[^${path.separator}^$]+(?:)*" replace="-I\0 " global="true"/>
这会产生以下内容:(
-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 再次运行它以摆脱这两个字符?您是否希望它们出现在数据的其他地方?
-
不,但第二个表达式是什么?只想删除;和:
-
创建了一篇展示这种方法的帖子。请注意它如何使用 override 来重用相同的属性。
标签: regex ant ant-contrib