I need to extract the email address out of this mailbox string.
I thought of str_replace
but the display name and the email address is not static so I don’t know how to do this using regular expressions.
Example: "My name <[email protected]>
" should result in "[email protected]
".
Any ideas?
Thanks Matthy
You can use imap_rfc822_parse_adrlist
to parse that address:
$addresses = imap_rfc822_parse_adrlist('My name <[email protected]>');
at face value, the following will work:
preg_match('~<([^>]+)>~',$string,$match);
but i have a sneaking suspicion you need something better than that. There are a ton of "official" email regex patterns out there, and you should be a bit more specific about the context and rules of the match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With