see re
EDIT: But be warned that executing unfiltered regexes from user input is as dangerous as executing plain Perl code.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
DB<3> use re "debug"; print 'abcdc' =~ /(.).*\1/ Compiling REx "(.).*\1" Final program: 1: OPEN1 (3) 3: REG_ANY (4) 4: CLOSE1 (6) 6: STAR (8) 7: REG_ANY (0) 8: REF1 (10) 10: END (0) minlen 1 Matching REx "(.).*\1" against "abcdc" 0 <> <abcdc> | 0| 1:OPEN1(3) 0 <> <abcdc> | 0| 3:REG_ANY(4) 1 <a> <bcdc> | 0| 4:CLOSE1(6) 1 <a> <bcdc> | 0| 6:STAR(8) | 0| REG_ANY can match 4 times out of 2 +147483647... 5 <abcdc> <> | 1| 8:REF1: "a"(10) | 1| failed... 4 <abcd> <c> | 1| 8:REF1: "a"(10) | 1| failed... 3 <abc> <dc> | 1| 8:REF1: "a"(10) | 1| failed... 2 <ab> <cdc> | 1| 8:REF1: "a"(10) | 1| failed... 1 <a> <bcdc> | 1| 8:REF1: "a"(10) | 1| failed... | 0| failed... 1 <a> <bcdc> | 0| 1:OPEN1(3) 1 <a> <bcdc> | 0| 3:REG_ANY(4) 2 <ab> <cdc> | 0| 4:CLOSE1(6) 2 <ab> <cdc> | 0| 6:STAR(8) | 0| REG_ANY can match 3 times out of 2 +147483647... 5 <abcdc> <> | 1| 8:REF1: "b"(10) | 1| failed... 4 <abcd> <c> | 1| 8:REF1: "b"(10) | 1| failed... 3 <abc> <dc> | 1| 8:REF1: "b"(10) | 1| failed... 2 <ab> <cdc> | 1| 8:REF1: "b"(10) | 1| failed... | 0| failed... 2 <ab> <cdc> | 0| 1:OPEN1(3) 2 <ab> <cdc> | 0| 3:REG_ANY(4) 3 <abc> <dc> | 0| 4:CLOSE1(6) 3 <abc> <dc> | 0| 6:STAR(8) | 0| REG_ANY can match 2 times out of 2 +147483647... 5 <abcdc> <> | 1| 8:REF1: "c"(10) | 1| failed... 4 <abcd> <c> | 1| 8:REF1: "c"(10) 5 <abcdc> <> | 1| 10:END(0) Match successful! cFreeing REx: "(.).*\1" DB<4>
In reply to Re: regex step counting
by LanX
in thread regex step counting
by Random_Walk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |