从邮箱字符串获取邮箱地址 [英] Get email address from mailbox string

查看:154
本文介绍了从邮箱字符串获取邮箱地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从邮箱字符串中提取电子邮件地址。
我想到了 str_replace ,但显示名称和电子邮件地址不是静态的,所以我不知道如何使用正则表达式。

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.

示例:我的名字< email@example.com> 应该导致

Example: "My name <email@example.com>" should result in "email@example.com".

任何想法?

感谢
Matthy

Thanks Matthy

推荐答案

在面值,以下将工作:

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.

这篇关于从邮箱字符串获取邮箱地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆