[Chicago-talk] Regex question

Kent Cowgill kent at c2group.net
Thu Apr 28 06:27:26 PDT 2011


 Or perhaps,

 $_ =~ s/Hello(?:\s\w+)?,/$ES/g;

 So it optionally includes a space followed by a word, and doesn't 
 bother to capture the grouping.

 On Thu, 28 Apr 2011 08:05:27 -0500, Mike Raffety 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

-- 
 Kent Cowgill                                     kent at c2group.net

 http://kentcowgill.org/blog           http://youtube.com/kcowgill
 http://kentcowgill.org/photos   http://flickr.com/people/kcowgill


More information about the Chicago-talk mailing list