In article <> ,
(cayenne) wrote:
> I have $mail_address = 'fred jones <>'
>
> I want to use regular expressions to just parse out the userid here of
> fred_jones
>
> I'm trying things like this:
>
> $mail_address =~ /\w+@/;
What you seem to be asking for is this:
my ($user_id) = ($mail_address =~ m/(\w+)@/);
However, please note that \w doesn't really have the complete set of
valid characters to prefix the '@' sign in an email address.
Just off the top of my head, I know that '.', '-', '?', '=', and more
are valid. Possibly any unicode character other than whitespace and '@'
are valid. It might even be valid to have '<' in an email address.
At the very least, you probably want
my ($user_id) = ($mail_address =~ m/([\w.-+=]+)@/);
HTH,
Ricky
--
Pukku