in reply to Tidying and simplifying a regular expression
It's relatively easy to spot that it's just a (?:..........)
It could just as easily be two `(?:...)` back to back. Therefore, tidying this up requires a complete regexp parser. And since Perl regex patterns can contain arbitrary Perl code, you also need a complete Perl parser if the pattern includes `(?{...})` or `(??{...})`.
So no, it's immensely hard to spot that it's just `(?:...)`.
It might be easier to address the problem at the source, which means replacing
withmy $augmented_pattern = "$re"; ... my $re = qr/$augmented_pattern/;
my ($pattern, $mods) = re::regexp_pattern($re); ... my $re = eval("qr/\$pattern/$mods") or die $@;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Tidying and simplifying a regular expression
by Dallaylaen (Chaplain) on Dec 13, 2017 at 07:13 UTC |
In Section
Seekers of Perl Wisdom