On Tue, May 6, 2014 at 10:30 PM, Danny Wong (dannwong)
<[email protected]> wrote:
> Both string are possible outputs, so I want to be able to grep for the
> username only.
Well, if the username will always be either the only thing between
'by' and 'on', or in parens if it's not...
#! /usr/bin/env perl
use strict;
use warnings;
use 5.010;
my @strings = (
"^Modifications made by Danny Wong (danwong) on 2014/05/06 18:27:48
from database brms" ,
"^Modifications made by danwong on 2014/05/06 18:27:48 from database brms²",
);
foreach my $string ( @strings ) {
my( $match ) = $string =~ /by (.*?) on/;
if ( $match and $match =~ /\(([^)]+)\)/ ) {
$match = $1;
}
say "Matched '$1' in '$string'"
if $match;
}
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/