[Chicago-talk] Regex question

Richard Reina richard at rushlogistics.com
Thu Apr 28 10:18:38 PDT 2011


   Good to know. Thanks, I will add the ?.
>  
>  Chicago.pm chatter <chicago-talk at pm.org> wrote:  Oops yeah typo. I mean ? before the , > s/Hello.*?,/$ES/g;
 > 
>  > On Thu, Apr 28, 2011 at 11:51 AM, Scott Sexton <scott.sexton at gmail.com> wrote:
>   You're actually going to want to use it with a ?
> in there: > s/Hello.*,?/$ES/g;
 > Otherwise it's greedy and will replace everything
> from Hello through the last comma instead of the first
> comma.
 > ~Scott >  > 
>  
>  > On Thu, Apr 28, 2011 at 9:27 AM, Richard Reina <richard at rushlogistics.com> wrote:
>   
>  This worked great.
>  
>  Thanks!
>  > 
>  
>  ---- Chicago.pm chatter <chicago-talk at pm.org> wrote:
>  >
>  > Change the "Hello," to "Hello.*,", so it includes
> any characters between
>  > the salutation and the comma.
>  >
>  > Richard Reina wrote, On 4/28/2011 7:34 AM:
 >  > > > I have the code below that replaces the string
> "Hello," with a scalar $ES which consists of "Hello
> " . $persons_first_name ",";  It works fine.  However,
> what I can't figure out is how to make it also substitute
> a string that already has a first name after hello.
>  For example, if finds Hello Kim, I want it to replace
> it with $ES.  Sorry for my ignorance.  Any help would
> be greatly appreciated.
>  > >
>  > > Thanks,
>  > >
>  > > Richard
>  > >
>  > > sub change_salutation {
>  > >
>  > > my ($ES) = @_;
>  > >
>  > > @ARGV = qw(L_FILE);
>  > >
>  > > $^I="";
>  > >
>  > > while (<>) {
>  > >
>  > >     $_ =~ s/Hello,/$ES/g;
>  > >     $print $_;
>  > >
>  > > }
>  > >
>  > > } # end of sub
>  > >
>  > >
>  > > }
>  > >
>  > >
>  > > }
> 
>  > > Chicago-talk mailing list
>  > > Chicago-talk at pm.org
>  > > http://mail.pm.org/mailman/listinfo/chicago-talk
>  > >
> 
>  > Chicago-talk mailing list
>  > Chicago-talk at pm.org
>  > http://mail.pm.org/mailman/listinfo/chicago-talk
>  >
>  _______________________________________________
>  Chicago-talk mailing list
>  Chicago-talk at pm.org
>  http://mail.pm.org/mailman/listinfo/chicago-talk
 
  
 
 
 
  
 
  
 
 -- Richard Reina Rush Logistics, Inc. Watch our 3
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110428/f53b6e8e/attachment.html>


More information about the Chicago-talk mailing list