小编Mr.*_*ang的帖子

为什么/\w +:/和/\S +:/处理回溯不同?

我使用regex101分析了这两个正则表达式.我认为回溯/\S+:/是正确的.但我无法理解这种差异.我错了吗?

regex101.com

regex pcre backtracking

16
推荐指数
2
解决办法
381
查看次数

捕获组VS非捕获组

我试图测试捕获和不捕获正则表达式组的性能。顺便说一下,捕获组和非捕获组之间的区别很小。这个结果正常吗?

[root@Sensor ~]# ll -h sample.log
-rw-r--r-- 1 root root 21M Oct 20 23:01 sample.log

[root@Sensor ~]# time grep -ciP '(get|post).*' sample.log
20000

real    0m0.083s
user    0m0.070s
sys     0m0.010s

[root@Sensor ~]# time grep -ciP '(?:get|post).*' sample.log
20000

real    0m0.083s
user    0m0.077s
sys     0m0.004s
Run Code Online (Sandbox Code Playgroud)

regex

4
推荐指数
2
解决办法
1278
查看次数

标签 统计

regex ×2

backtracking ×1

pcre ×1