Regex 用正则表达式剪切子串
我想用正则表达式提取subversion URL的分支或标记信息 摘录:Regex 用正则表达式剪切子串,regex,ant,Regex,Ant,我想用正则表达式提取subversion URL的分支或标记信息 摘录: branches-1.0 tags-1.0.0 摘录: branches-1.0 tags-1.0.0 注意:我还想用“-”替换“/”。我想使用propertregex任务在ant脚本中提取它,如 <propertyregex property="svn.Branch" input="${svn.URL}" regexp="/myproject/([^/]+)" select="\1"/> 及 要获得
branches-1.0
tags-1.0.0
摘录:
branches-1.0
tags-1.0.0
注意:我还想用“-”替换“/”。我想使用propertregex任务在ant脚本中提取它,如
<propertyregex property="svn.Branch" input="${svn.URL}" regexp="/myproject/([^/]+)" select="\1"/>
及
要获得上述结果,我需要更改什么?您还需要一个捕获组来映射版本号
<propertyregex property="svn.Branch" input="${svn.URL}" regexp="/myproject/([^/]+)/([^/]+)" select="\1-\2"/>