Hi -

> -----Original Message-----
> From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 04, 2003 2:16 PM
> To: Hanson, Rob
> Cc: Gregg R. Allen; [EMAIL PROTECTED]
> Subject: Re: Simple Regex Problem.
>
>
> 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"
> >
> > (The "blahs", of course, are not literal, but can be anything.)
> >
> > He wants the subject field to look like: "[EMAIL PROTECTED]"
> >
> > I know this can be done very easily with a Perl regex but I've been
> > away from Perl for about two years and I've forgotten
> > very much.
> >
> > Thanks in advance,
> >
> > Gregg R. Allen
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>

This script works on my machine (note the single quotes
when assigning to $data):

#!/usr/bin/perl
use strict;
use warnings;

 my $data = 'BlahBlahBlahBlah From:
BlahsvilleDude<[EMAIL PROTECTED]>BlahBBlahBBlah';
 $data =~ s/^.*<([^>]*)>.*$/$1/;
 print "$data\n";

Aloha => Beau;



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

Reply via email to