Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 用正则表达式剪切子串_Regex_Ant - Fatal编程技术网

Regex 用正则表达式剪切子串

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"/> 及 要获得

我想用正则表达式提取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"/>


要获得上述结果,我需要更改什么?

您还需要一个捕获组来映射版本号

<propertyregex property="svn.Branch" input="${svn.URL}" regexp="/myproject/([^/]+)/([^/]+)" select="\1-\2"/>