Get email address from mailbox string

前端 未结 5 1764
梦如初夏
梦如初夏 2021-01-12 10:53

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 kno

5条回答
  •  长发绾君心
    2021-01-12 11:27

    I'm coming from a time and from projects where Regex was to expensive for easy string extraction.

    $s = 'My name ';
    $s = substr(($s = substr($s, (strpos($s, '<')+1))), 0, strrpos($s, '>'));
    

    Results in

    email@gmail.com
    

提交回复
热议问题