in reply to Grouped characters inside character class.
This works:
which matches:use strict; use warnings; my $source = 'Posted by mad max beyond eggdome on September 04, 2003'; if ( $source =~ /^Posted by (.*?) on /i ) { print qq("$1") . "\n"; }
C:\>perl -MYAPE::Regex::Explain -e "print YAPE::Regex::Explain->new(qr +/^Posted by (.*?) on /)->explain()" The regular expression: (?-imsx:^Posted by (.*?) on ) 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): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- Posted by 'Posted by ' ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- on ' on ' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
-enlil
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Grouped characters inside character class.
by m.att (Pilgrim) on Jun 02, 2006 at 01:49 UTC | |
by Enlil (Parson) on Jun 02, 2006 at 02:13 UTC | |
by blokhead (Monsignor) on Jun 02, 2006 at 02:56 UTC | |
Re^2: Grouped characters inside character class.
by the_0ne (Pilgrim) on Jun 02, 2006 at 01:45 UTC |
In Section
Seekers of Perl Wisdom