Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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 - Fatal编程技术网

在模式匹配后操作regex变量

在模式匹配后操作regex变量,regex,Regex,搜索正则表达式为: _(01|02|03|04)_ _$1_ 替换表达式为: _(01|02|03|04)_ _$1_ 结果是: _01_/_02_/_03_/_04_ (depending on the match) 如何操作变量,使其去掉0以返回单个数字: _1_/_2_/_3_/_4_ ?使匹配为:0(1 | 2 | 3 | 4)替换为$1使匹配为:0(1 | 2 | 3 | 4)替换为$1

搜索正则表达式为:

_(01|02|03|04)_
_$1_
替换表达式为:

_(01|02|03|04)_
_$1_
结果是:

_01_/_02_/_03_/_04_ (depending on the match)
如何操作变量,使其去掉0以返回单个数字:

_1_/_2_/_3_/_4_

使匹配为:
0(1 | 2 | 3 | 4)
替换为
$1
使匹配为:
0(1 | 2 | 3 | 4)
替换为
$1