develooper Front page | perl.beginners | Postings from February 2002

RE: select text

Thread Previous | Thread Next
From:
John Edwards
Date:
February 5, 2002 09:25
Subject:
RE: select text
Message ID:
2FB59B145095D511A7C90050BAC349F3173197@MAIL
You can use the following code...

$email = 'Name LastName <name@domain.com>';
$email =~ /<([\w@.]+)>/;
$email = $1;
print $email;

As you seem relatively new to this, here is a breakdown

$email = 'Name LastName <name@domain.com>';
# Just define the data for this demo

$email =~ /<([\w@.]+)>/;
# This is a regular expression which looks for a left angle bracket <
# Followed by either []
# a word character \w
# or an at sign @
# or a full stop .
# Look for at least one of each of these, but more if possible +
# Save the stuff you find using this criteria in the special variable ()
# But don't look past the right angle bracket

# Hopefully that makes some sense ;)

$email = $1;

# Now store the data that was matched and stored in the special variable $1
back into the $email var

print $email;
# You know this one, right ;)

HTH

John

-----Original Message-----
From: Roman Fordinal [mailto:fordinal@slovanet.sk]
Sent: 05 February 2002 17:11
To: beginners@perl.org
Subject: select text



  i need get e-mail adrees from string
  
  $email="Name LastName <name@domain.com>"
  to
  $email="name@domain.com"

  why get it????  :((((

:
:. s pozdravom
:..                      Roman Fordinal
:..                      project manager
:.:
:.: WebCom s.r.o. - Internet Advertising Agency & Design Studio
:.: Stanicna 12, Zohor, Slovakia
:.: Tel: +421.02.65458251, +421.0907.178147
:.: fordinal@slovanet.sk


-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About