View Full Version : Remove part of a string using // as a delimiter

07-21-2008, 03:30 PM

I have some email addresses being imported into a PHP script I'm working on, I need to get them from this form;

mark hankins<markhankins@example.com>

to this format;


So far I have managed to remove a lot of the junk characters using str_replace, but now I'm left with addresses still with an alias, but separated by \name\email@address.com.

If only I could get rid of the slashes and the bit between them I'd be sorted.

Any advice? (Please be gentle, I'm a noob!)

Thanks in advance.

07-21-2008, 03:36 PM
$mail = 'mark hankins<markhankins@example.com>';
$mail = preg_replace("/^[^<]+<([^>]+)>$/","$1",$mail);
echo $mail."<br>";


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum