How could I extract the email part from all of the following strings cases:
"Robert Donhan" <[email protected]>
Robert Donhan <[email protected]>
"Robert Donhan" [email protected]
Robert Donhan [email protected]
Thanks
How could I extract the email part from all of the following strings cases:
"Robert Donhan" <[email protected]>
Robert Donhan <[email protected]>
"Robert Donhan" [email protected]
Robert Donhan [email protected]
Thanks
Could you try with this regex:
([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})
Anyway, I suggested this site: TXT2RE
Not completely correct but the following regex mostly works:
[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}
with case insensitive option
{2,4} should be {2,6} (Don't leave out .MUSEUM and .TRAVEL!If you do not necessarily need a regular expression, you could use imap_rfc822_parse_adrlist or mailparse_rfc822_parse_addresses to get both the address and the name.