in reply to Re^2: Bug in script, regex help req extreme urgent
in thread Bug in script, regex help req extreme urgent
Tip #9 from the Basic debugging checklist:
Demystify regular expressions by installing and using the CPAN module YAPE::Regex::Explain
So:
#! perl use strict; use warnings; use YAPE::Regex::Explain; my $re = qr/(?<=module )$ARGV[2].*?([\\(;])/; print YAPE::Regex::Explain->new($re)->explain();
Output:
15:40 >perl 566_SoPW.pl FILE OLD NEW The regular expression: (?-imsx:(?<=module )NEW.*?([\\(;])) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?<= look behind to see if there is: ---------------------------------------------------------------------- module 'module ' ---------------------------------------------------------------------- ) end of look-behind ---------------------------------------------------------------------- NEW 'NEW' ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [\\(;] any character of: '\\', '(', ';' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- 15:40 >
See also perlretut and perlre.
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Bug in script, regex help req extreme urgent
by sid.verycool (Novice) on Mar 21, 2013 at 03:42 UTC | |
Re^4: Bug in script, regex help req extreme urgent
by sid.verycool (Novice) on Mar 10, 2013 at 07:22 UTC | |
by jms53 (Monk) on Mar 10, 2013 at 13:51 UTC |
In Section
Seekers of Perl Wisdom