如何捕获电子邮件地址字符串 [英] how to catch the email address string

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

问题描述

嗨:


我正在尝试过滤scammer的电子邮件地址。


通常他们会在yahoo dot com (或y // a / hoo dot com ...)


在(雅虎)的每个字母中,他们将放置一个或多个非字母或非数字字符



使用ReExp捕获这些字符串的最佳方法是什么,我注意到\W可以匹配任何非字符,但只有字符,而不是字符 s



// =====这一个仅适用于y ahoo之间的一个char =======


objRegEx = new Regex(" y [\\W] a [\ \ W] h [\\ W] o [\\ W] o");
if(objRegEx.IsMatch(" y = a + h / o * o")== true)
{
Response.Write(" it 'sa Match!");
}


// ====================== ================================



(我想我只需要抓住雅虎,不要担心网络公司)。



任何建议都会很棒。谢谢。



Jt

解决方案

< blockquote> 正则表达式中的以下字符串将捕获yahoo之间的任何非字符或字符

y [\\W] * a [\\\ \\ w] * h [\\ W] * o [\\W] + o |
y [\\ W ] * a [\\W] * h [\\ W] + o [\\ W] * o | y [\\ W] * a [\\W] + h [\\ W] * o [\ \ W] * o | y [\\\ \\ w] + a [\\W] * h [\\ W] * o [\\ W] * o

Hi:

I am trying to filter scammer's email address.

Usually they will wirte:  myName at y-a-h-o-o dot com  (or y//a/h-o-o dot c-o-m ...)

in each char of (y a h o o) they will put one or more than one non-letter or non-numerals char(s)

 

What is the best way to catch those string using ReExp, I notice there is \W can matche any nonword character, but only character, not characters.

 

//=====this one works only for one char in between of y a h o o =======

objRegEx = new Regex("y[\\W]a[\\W]h[\\W]o[\\W]o");
        if (objRegEx.IsMatch("y=a+h/o*o") == true )
        {
            Response.Write("it's a Match!");
        }

//======================================================

 

(I think I only need catch yahoo, don't worry about dot com).

 

Any suggestion will be great. Thanks.

 

Jt

解决方案

The following string in your regular expression will catch any non-character or chacters inbetween y a h o o

y[\\W]*a[\\W]*h[\\W]*o[\\W]+o|
y[\\W]*a[\\W]*h[\\W]+o[\\W]*o|y[\\W]*a[\\W]+h[\\W]*o[\\W]*o|y[\\W]+a[\\W]*h[\\W]*o[\\W]*o


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

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