Gregg R. Allen wrote:
> It was close but what I got is : "JohnDoe.com"  Instead of
> "[EMAIL PROTECTED]".
> 
> I think it has something to do with escaping the "@" sign.  I've been
> experimenting, but without much luck.
> 
> Thanks,
> 
> Gregg
> 
> 
> On Tuesday, Mar 4, 2003, at 15:31 US/Mountain, Hanson, Rob wrote:
> 
>> Try this...
>> 
>> my $data = "BlahBlahBlahBlah From: BlahsvilleDude
>> <[EMAIL PROTECTED]>BlahBBlahBBlah"
>> $data =~ s/^.*<([^>]*)>.*$/$1/;
>> 
>> Broken down...
>> 
>> s/ = substitute
>> ^ = beginning of string
>> .* = anything, zero or more times
>> < = "<"
>> ( = start trapping text
>> [^>]* = anything but ">", zero or more times
>> )> = stop trapping text
>> .* = anything, zero or more times
>> $ = end of string
>> /$1/ = replace matched text with the trapped text
>> 
>> Rob
>> 
>> -----Original Message-----
>> From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, March 04, 2003 5:25 PM
>> To: [EMAIL PROTECTED]
>> Cc: Gregg R. Allen
>> Subject: Simple Regex Problem.
>> 
>> 
>> So my boss just told me that he doesn't like the fact that the
>> "From:" field in our email database typically looks like:
>> 
>> "BlahBlahBlahBlah From: BlahsvilleDude
>> <[EMAIL PROTECTED]>BlahBBlahBBlah"
>> 
 I had to change as follows:
my $data = 'BlahBlahBlahBlah From: BlahsvilleDude
<[EMAIL PROTECTED]>BlahBBlahBBlah';

printf "bf:%-s\n", $data;

$data =~ s/^.*<([^>]*)>.*$/$1/gs;

printf "af:%-s\n", $data;

but it does work though you need to use single quotes around the data as it is coming 
in.  If you can have the line feed in there, then you will need the s to handle the 
possible line feed.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for 
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to