English 中文(简体)
NED RegExprer 匹配组组,共8个,包含2+大写、2+小写和1+号
原标题:Need RegExpr matching group of 8 containing, 2+ uppercase, 2+ lowercase and 1+ number
  • 时间:2012-05-26 22:19:15
  •  标签:
  • filter
  • spam

我试图用符合下列情况的正则表达式创建一个垃圾邮件过滤器。

  • There is a group of exactly 8 alphanumeric characters to be matched.
  • It must contain 2 or more uppercase letters;
  • AND it must contain 2 or more lowercase letters;
  • AND it must contain 1 or more numbers.

到目前为止,我所能想到的只有这个:

(?i)[A-Za-z0-9]{8}

我的代码确实符合8个混合案件组,但并不强制使用上下两个案件组,也没有规定每种类型必须发生多少次。所以,我把它与其他总是存在于有关信件中的必须拥有的事物组合起来。

以下是我试图检测的模式样本:

WbNDSk9e

这是垃圾邮件 URL 的一部分 。 我所看到的其它组别也遵循相同的模式, 即每个 CUC 和 LC 字母至少有2个, 1 个或 1个以上, 并且总是有 8 个字符 。 我还没有看到其他字符或变化 。

据我所知,我唯一能够使用的开关是打开“? ” ( ) ( ) 的“? ” ( ) 敏感度开关。 我在一些答复中看到的其他开关在程序上不起作用。 我从一条单行 RegExprer 规则中要求太多吗?

我目前使用雷杰斯匹配测试我的规则 我的反垃圾邮件程序使用同样的引擎

问题回答
^(?=.*?[A-Z].*?[A-Z])(?=.*?[a-z].*?[a-z])(?=.*?d).{8}$

折断 :

(?=*? [A- Z]. *? [A-Z]) 强制要求至少两个大写字母。

(?=. *? [a-z]. *? [a-z] 强制要求至少两个小写字母。

(?=. *? d) 强制力至少 1 位数 。

caritt 和 $blent 与整个字符串相匹配的美元力量 。

您不希望有 < code> (? i) 的旗帜, 因为它会使其不区分大小写 。





相关问题
How do I reset or override IE CSS filters?

I m using the proprietry MS filter property to try and create a non ugly equivalent to css3 text-shadow and box-shadow; I was actually doing really well until I hit this problem. It looks like when ...

PHP filter string input, cut off all newlines, 1 chars

I m writing in PHP! There s a user string input, and I want to cut off all newlines,1 chars that are more than 1 in a row (avoid <br /><br />...). example: I am a SPaMmEr! would ...

The Fastest DataStructure to Filter with in C#

Currently we are filtering and sorting data with a datatable. /// <summary> /// Filters the data table and returns a new data table with only the filtered rows. /// </summary>...

How to dynamically update a ListView on Android [closed]

On Android, how can I a ListView that filters based on user input, where the items shown are updated dynamically based on the TextView value? I m looking for something like this: -------------------...

Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Best method to scale DropShadows in AS3?

I m creating a flash application that makes use of both the dropShadow filter and scaling of various sprites. And therein lies the problem: This filter supports Stage scaling. However, it does ...

热门标签