通过正则表达式调试/步进有哪些工具?
虽然有许多优秀的在线和离线工具用于测试正则表达式,但我还没有找到一种工具(除了RegexBuddy),它让我看到正则表达式引擎用来查找匹配的步骤(或者发现没有匹配, 对于这个问题。)
有谁知道这样做的任何工具? 我最初排除RegexBuddy的原因是因为它是商业的,我宁愿在决定付费之前查看我的选项。
为了更清楚地表达我想要的内容,下面是来自RegexBuddy的一个截图(来自他们的主页):http://img166.imageshack.us/img166/1272/debug.png
也许RegexCoach提供你正在寻找的东西......
http://weitz.de/regex-coach/
在Perl中,你总是可以use re 'debug';
或者use re 'debugcolor';
例如,如果你在Perl中输入:
use strict;
use warnings;
use 5.010;
use re 'debug';
# using the same strings as the question's image for reference:
my $str = 'Even if I do say so myself: "RegexBuddy is awesome"';
$str =~ /(Regexp?Buddy is (awful|acceptable|awesome))/;
这就是你得到的结果:
Compiling REx "(Regexp?Buddy is (awful|acceptable|awesome))"
Final program:
1: OPEN1 (3)
3: EXACT <Regex> (6)
6: CURLY {0,1} (10)
8: EXACT <p> (0)
10: EXACT <Buddy is > (14)
14: OPEN2 (16)
16: EXACT <a> (18)
18: TRIEC-EXACT[cw] (29) # this is a new feature in Perl 5.10
<wful>
<cceptable>
<wesome>
29: CLOSE2 (31)
31: CLOSE1 (33)
33: END (0)
anchored "Regex" at 0 floating "Buddy is a" at 5..6 (checking floating) minlen 19
Guessing start of match in sv for REx "(Regexp?Buddy is (awful|acceptable|awesome))" against 'Even if I do say so myself: "RegexBuddy is awesome"'
Found floating substr "Buddy is a" at offset 34...
Found anchored substr "Regex" at offset 29...
Starting position does not contradict # /^/m...
Guessed: match at offset 29
Matching REx "(Regexp?Buddy is (awful|acceptable|awesome))" against 'RegexBuddy is awesome"'
29 <'lf: "'> <RegexBuddy> | 1:OPEN1(3)
29 <'lf: "'> <RegexBuddy> | 3:EXACT <Regex>(6)
34 <Regex> <Buddy is a> | 6:CURLY {0,1}(10)
EXACT <p> can match 0 times out of 1...
34 <Regex> <Buddy is a> | 10: EXACT <Buddy is >(14)
43 <y is > <'awesome"'> | 14: OPEN2(16)
43 <y is > <'awesome"'> | 16: EXACT <a>(18)
44 < is a> <'wesome"'> | 18: TRIEC-EXACT[cw](29)
44 < is a> <'wesome"'> | State: 2 Accepted: 0 Charid: 2 CP: 77 After State: 3
45 < is aw> <'esome"'> | State: 3 Accepted: 0 Charid: 7 CP: 65 After State: 10
46 < is awe> <'some"'> | State: 10 Accepted: 0 Charid: b CP: 73 After State: 11
47 < is awes> <'ome"'> | State: 11 Accepted: 0 Charid: c CP: 6f After State: 12
48 < is aweso> <'me"'> | State: 12 Accepted: 0 Charid: d CP: 6d After State: 13
49 < is awesom> <'e"'> | State: 13 Accepted: 0 Charid: 7 CP: 65 After State: 14
50 < is awesome> <'"'> | State: 14 Accepted: 1 Charid: 3 CP: 0 After State: 0
got 1 possible matches
only one match left: #3 <wesome>
50 < is awesome> <'"'> | 29: CLOSE2(31)
50 < is awesome> <'"'> | 31: CLOSE1(33)
50 < is awesome> <'"'> | 33: END(0)
Match successful!
Freeing REx: "(Regexp?Buddy is (awful|acceptable|awesome))"
(注意:我改变了输出的一些部分,以便更好地突出显示)
它不如RegexBuddy强大,但它是一个简单的在线界面:http://www.gskinner.com/RegExr/
您可以将鼠标悬停在表达部分,并会告诉您它在做什么。 非常基本,但是当你做一些愚蠢的事情时它确实可以节省时间。
链接地址: http://www.djcxy.com/p/76965.html上一篇: What tools are there for debugging/stepping through a regular expression?