This works:
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";
}
which matches:
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