On Tue, May 6, 2014 at 10:19 PM, Danny Wong (dannwong)
<dannw...@cisco.com> 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 like:

#! /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 ) {
  say "Matched '$1' in '$string'"
    if $string =~ /(danwong)/;
}

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to