2011-12-01 65 views
2

我有以下几点:蚂蚁propertyregex的行为出现异常

<propertyregex property="myProp" input="${someInput}" 
       regexp="(.*)" 
       replace="-f -d '\1'" 
       override="true"/> 

的propertyregex的目的是采取someInput的价值,并把它单qoutes内,并与-f和-d标志前面加上它。 如果我设置someInput到MyString的,我希望会是这个结果:

-f -d 'myString' 

,但我得到:

-f -d 'myString'-f -d '' 

谁能解释其中尾随-f -d'从何而来?

回答

0

正则表达式匹配两次。一旦它匹配整个字符串,然后匹配字符串末尾的空字符串(因为星号允许零长度匹配)。

使用

<propertyregex property="myProp" input="${someInput}" 
       regexp="^.*" 
       replace="-f -d '\0'" 
       override="true"/> 

\0包含了整场比赛,所以你也不需要捕获括号)。

另请参阅this question

+0

非常感谢Tim! – Liz