Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple regular expression

Status
Not open for further replies.

mouncifb

Technical User
Feb 18, 2008
5
0
0
US
this must be a stupid question, I am newbie in perl.

I have a variable called

$email = "mail: firstname.lastname@domain.com";

I want to return just firstname.lastname@domain.com and store
it in another variable called $email2.

I know it's a perl regular expression but I have no clue.

thanks
 
No need for a regexp if it's always in that format:
Code:
my $extracted_email = substr( $email, 6 );
 
hopefully you have varibale using single-quotes:

$email = 'mail: firstname.lastname@domain.com';

or the @ symbol is escaped in your double-quoted string. Otherwise perl will interpolate @domain as an array and you will end up with:

firstname.lastname.com

or if @domain happend to be a valid array it would be expanded into the string.


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top