如何使用REGEXP MySQL函数查找超过2个点的电子邮件? [英] How to find email with more than 2 dots using REGEXP MySQL function?

查看:115
本文介绍了如何使用REGEXP MySQL函数查找超过2个点的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大量的垃圾邮件帐户的用户数据库,如 johnha.r.rold.t.ho.mp.so.njunio.r@gmail.com ofvst.p.rqlsy.j@gmail.com ,我想用一个查询删除它们(而不是做一个php脚本,解析所有的数据库)。

I have a big user database with a lot of spammy email account, like j.o.hnha.r.rold.t.ho.mp.so.n.j.u.n.io.r@gmail.com or o.f.vst.p.rqlsy.j@gmail.com and I want to remove them with one queries (instead of doing a php script that parses all the database).

我看到MySQL有一个REGEXP功能,但很难使用dot。我试过很多东西,如:

I see MySQL have a REGEXP function, but it's hard to use it with "dot". I tried lots of things like :


  • SELECT * FROM users WHERE email REGEXP'([[...] ]){2,}'

  • SELECT * FROM users WHERE email REGEXP'(\\。){2,} '(。*)[[...]] {2}(。*) )'

  • SELECT * FROM users WHERE email REGEXP '([[...]]){2,}'
  • SELECT * FROM users WHERE email REGEXP '(\\.){2,}'
  • SELECT * FROM users WHERE email REGEXP '(.*)[[...]]{2}(.*)'

每个失败。

任何想法?

推荐答案

这个怎么样?

SELECT * FROM users WHERE email REGEXP '[.].*[.].*@';

在@之前搜索两个(或更多)个点(这仍然允许多点域名如.co.uk等)。

this searches for two (or more) dots before @ (which would still allow multi-dot domain names like .co.uk etc).

但是,您应该考虑一些用户在其用户名中可能真的有多个点的可能性,这仍然是合法的。

However, you should consider the possibility that some users may really have multiple dots in their username as well, and that will still be legit.

这篇关于如何使用REGEXP MySQL函数查找超过2个点的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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