[Chicago-talk] Regex question

David Young davidy at nationalcycle.com
Thu Apr 28 06:09:11 PDT 2011


Richard,

$_ =~ s/Hello.*,/$ES/g

should do the trick.  To learn and/or test goto regextester.com.  Here is
your example:

[image: re.jpg]

ydy


On Thu, Apr 28, 2011 at 7:34 AM, Richard Reina <richard at rushlogistics.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110428/017da1c8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 42656 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110428/017da1c8/attachment-0001.jpe>


More information about the Chicago-talk mailing list