On Wed, May 7, 2014 at 1:19 AM, Danny Wong (dannwong) <dannw...@cisco.com> 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 brms²; > > 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 think you want to anchor on 'made by' and either match between the (..) or the word and then end on 'on <date>'. So, something like: /.+made by (?:[a-zA-Z\ ]+\(([^\)]+\)|([^ ]+))/ (untested) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/