Please find below the tested code, same regular expression match both the
patterns:
my $string1 = "^Modifications made by Danny Wong (danwong) on 2014/05/06
18:27:48 from database brms";
my $string2 = "^Modifications made by danwong on 2014/05/06 18:27:48 from
database brms";
if ($string1=~/by.*
On 05/07/2014 01:40 AM, John SJ Anderson wrote:
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 ) = $s
On Tue, May 6, 2014 at 10:30 PM, Danny Wong (dannwong)
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;
On Wed, May 7, 2014 at 1:19 AM, Danny Wong (dannwong)
wrote:
> Hi Guys,
> I have the following strings.
>
> my $str1="^Modifications made by Danny Wong (danwong) on 2014/05/06
> 18:27:48 from database brms";
>
> #$str1="^Modifications made by danwong on 2014/05/06 18:27:48 from
> database
Both string are possible outputs, so I want to be able to grep for the
username only.
I tried this, but it works for the string without parentheses.
"^Modifications made by danwong on 2014/05/06 18:27:48 from database brms",
$str1 =~ /by.*?[(]?(.*?)[)]?\s+on/i;
The one with partheses gives me
On Tue, May 6, 2014 at 10:19 PM, Danny Wong (dannwong)
wrote:
> What is a regular expression where I can extract ³danwong² from either
> string (one string have () parentheses and the other doesn¹t have
> parentheses)?
I'm not entirely sure what you're trying to accomplish, but perhaps
something
Hi Guys,
I have the following strings.
my $str1="^Modifications made by Danny Wong (danwong) on 2014/05/06
18:27:48 from database brms";
#$str1="^Modifications made by danwong on 2014/05/06 18:27:48 from
database brms²;
What is a regular expression where I can extract ³danwong² from eith