Ask a Question related to PERL Miscellaneous, Design and Development.
-
ccwork #1
backtracking in regular expression matching
Hi,
For the pattern "(((.*)cd)*)*cdcd" and string "ababcdcdcdef", can
anyone tell me the detail meachanism of backtracking? This regular
expression have two level of backtracking, the "((.*)cd)*" and
"(((.*)cd)*)*", so which one take precedence?
Thanks.
ccwork Guest
-
Regular expression help
Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract... -
regular expression help..
On Thu, 28 Aug 2003 15:50:49 +0200 "point" <point@caanNOSPAMproduction.com> wrote: Don't cross post, it's considered bad form. /^-+$/ ... -
split() matching regular expression question - openwebmail bug...
Openwebmail seems to have a bug in the way it stores and retrieves data, especially passwords from a file called .pop3book. In .pop3book there... -
Regular Expression Help please
All, I have this regular expression which a guy here provided yesterday, this regexp parses an executable name from a log file, however it only... -
Regular Expression Matching
Hello, I am trying to figure out how to match a an email w/in a delimited line. ie: 1, 'John', 'Doe', 'I', 'john.doe@domain.ext' the list... -
Sam Holden #2
Re: backtracking in regular expression matching
On 16 Sep 2003 03:14:01 -0700, ccwork <ccwork@hotmail.com> wrote:
Matching occurs starting at the left, each "element" being greedy (unless> Hi,
> For the pattern "(((.*)cd)*)*cdcd" and string "ababcdcdcdef", can
> anyone tell me the detail meachanism of backtracking? This regular
> expression have two level of backtracking, the "((.*)cd)*" and
> "(((.*)cd)*)*", so which one take precedence?
specified otherwise with ?). Backtracking occurs when a match fails.
You have a '**' construct in the regex which will cause *large* amounts
of backtracking, since it leads to *lots* of ways of matching the same
string (even worse there's a .* inside that as well).
But it works from the left greedily, at each step. With backtracking
occuring when some part of the expression can't match. The backtracking
causes the previous greedy expression to match fewer characters (with
non-greedy expressions it would match more...).
--
Sam Holden
Sam Holden Guest
-
Thens #3
Re: backtracking in regular expression matching
On 16 Sep 2003 03:14:01 -0700
[email]ccwork@hotmail.com[/email] (ccwork) wrote:
# Hi,
# For the pattern "(((.*)cd)*)*cdcd" and string "ababcdcdcdef", can
# anyone tell me the detail meachanism of backtracking? This regular
# expression have two level of backtracking, the "((.*)cd)*" and
# "(((.*)cd)*)*", so which one take precedence?
You can use the 're' module to throw some more debug information to
you.
use re qw /debug/;
-- or --
use re qw /debugcolor/; # same with colored output
see perldoc re for more details.
Regards,
Thens.
Thens Guest
-
ccwork #4
Re: backtracking in regular expression matching
Hi,
But how to interpret the 500 lines output? Any website recommended?
Thanks.
"Thens" <thens@NOSPAMti.com>
???????:20030916174054.5c20a7b0.thens@NOSPAMti.com ...> On 16 Sep 2003 03:14:01 -0700
> [email]ccwork@hotmail.com[/email] (ccwork) wrote:
>
> You can use the 're' module to throw some more debug information to
> you.
>
> use re qw /debug/;
> -- or --
> use re qw /debugcolor/; # same with colored output
>
> see perldoc re for more details.
>
> Regards,
> Thens.
>
ccwork Guest



Reply With Quote

