使用正则表达式从电子邮件地址中过滤周期 [英] Filtering periods out of email addresses with regex

查看:123
本文介绍了使用正则表达式从电子邮件地址中过滤周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用正则表达式清理一组功能相当的gmail地址。你可能知道gmail hack中的哪个brunette.thomas @ gmail被gmail处理为\"brewandrew @ gmail。人们通过在他们的电子邮件地址中添加句点来进入抽奖活动的多个条目。

I need to clean a set of gmail addresses that are functionally equivalent using a regex. You may know of the gmail hack where "brunette.thomas@gmail" is treated by gmail as "brunetteandrew@gmail". People are entering multiple entries in a sweepstakes by adding periods to their email address.

我需要将其过滤到电子邮件地址的alpha组件,即转换:

I need to filter these down to just the alpha component of the email address, ie., turn:


brunettethomas@gmail.com

b.r.u.n.e.t.t.e.t.h.o.m.as@gmail.com

into:


brunettethomas@gmail.com

brunettethomas@gmail.com

不管期限多少。

有人可以帮我吗?

推荐答案

您可以使用它来匹配at-sign之前的所有时段:

You can use this to match all periods before the at-sign:

\.(?=.*@)

然后你可以全局替换为空字符串。这只适用于支持前瞻性的正则表达式方言(您尚未声明使用哪种方言)。

Then you can just globally replace it with null-string. This will only work on regexp dialects that support lookahead (you haven't stated which dialect you're using).

这篇关于使用正则表达式从电子邮件地址中过滤周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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