Regex ANT:多行属性上的正则表达式比较
在Apache Ant任务中,我尝试比较此命令的输出:Regex ANT:多行属性上的正则表达式比较,regex,ant,Regex,Ant,在Apache Ant任务中,我尝试比较此命令的输出: <exec executable="svn" outputproperty="svnTest"> <arg line="status ${GUI_BASE} -u -q" /> </exec> svnTest的值为 M 3234 C:\path\to\some\file1.txt M 3234 C:\path\to\some\fil
<exec executable="svn" outputproperty="svnTest">
<arg line="status ${GUI_BASE} -u -q" />
</exec>
svnTest
的值为
M 3234 C:\path\to\some\file1.txt
M 3234 C:\path\to\some\file2.txt
但以下情况的结果:
<regexp id="upd" pattern="^(\*).+/gm" />
<condition property="matches" value="true" else="false">
<matches string="${svnTest}">
<regexp refid="upd" />
</matches>
</condition>
isfalse
如何使其工作?您似乎希望获取第一个字符不是
M
的行
你可以用
pattern="^[^M].*"
这里,
-匹配字符串的开头^
-一个与除[^M]
M
-任何0个字符以上的字符,直到行尾*
pattern="^[^M].*"