hnfeng 发表于 2018-1-16 16:12:49

【分享、征集、请教】手机靓号正则表达式

本帖最后由 hnfeng 于 2018-1-16 16:16 编辑

【分享、征集、请教】手机靓号正则表达式

初学正则表达式,很手生,抱歉……

先使用正则表达式
(?<=\D)1\d{10}
从文本中提取手机号码,保存到字串中,然后再使用下面的正则。这样不需再考虑位数、前导符……等,可能会提高效率

除说明,下面的正则表达式默认是模式3。 用模式4时,取数组的0或1列。


号码的格式(或者称作样式),一个较直观的约定规则,便于理解,给普通用户看的,或者用户自定义输入指定格式用的:

ABCDEFGH 连续递增数字
   ABCD 可表示1234,2345,6789...
   ACEG 可表示1357,2468...
   ADG 可表示 147,258,369
   DCBA 可表示 4321,8765...
QRST 第二组连续递增数字
AAAA 重复数字
QQQQ 第二组重复数字
x 1个数字
* 0个或多个数字
j 1个或多个数字


请补充、请纠正下面的错误、请分享更好的正则表达式……


含一组连续递增数字组
1xxABCDEFGH
例如:13612345678,13823456789
正则:\b(1\d{2}(?:01234567|12345678|23456789))
1xx*ABCDEFG*
例如:13681234567,13823456781
正则:\b(1\d{2}\d*(?:0123456|1234567|2345678|3456789)\d*)\b
1xx*ABCDEF*
例如:13685234567,13864567891
正则:\b(1\d{2}\d*(?:012345|123456|234567|345678|456789)\d*)\b
1xx*ABCDE*
例如:13685234562,13864567821
正则:\b(1\d{2}\d*(?:01234|12345|23456|34567|45678|56789)\d*)\b
1xx*ABCD*
例如:13685534562,13864567921
正则:\b(1\d{2}\d*(?:0123|1234|2345|3456|4567|5678|6789)\d*)\b
1xx*ABC*
例如:13685953452,13867442567
正则:\b(1\d{2}\d*(?:012|123|234|345|456|567|678|789)\d*)\b
1xx*ACEG*
例如:13685913572,13824682567
正则:\b(1\d{2}\d*(?:0246|1357|2468|3579)\d*)\b
1xx*ADG*
例如:13625815712,13824688369,13802585369
正则:\b(1\d{2}\d*(?:147|258|369)\d*)\b


含一组连续递增数字组且位于尾部
1xxABCDEFGH
例如:13612345678,13823456789
正则:\b(1\d{2}(?:01234567|12345678|23456789))
1xxjABCDEFG
例如:13681234567,13842345678
正则:\b(1\d{2}\d+(?:0123456|1234567|2345678|3456789))
1xxjABCDEF
例如:13685234567,13862123456
正则:\b(1\d{2}\d+(?:012345|123456|234567|345678|456789))\b
1xxjABCDE
例如:13685623456,13864156789
正则:\b(1\d{2}\d+(?:01234|12345|23456|34567|45678|56789))\b
1xxjABCD
例如:13685513456,13864515678
正则:\b(1\d{2}\d+(?:0123|1234|2345|3456|4567|5678|6789))\b
1xxjABC
例如:13685953123,13867442567
正则:\b(1\d{2}\d+(?:012|123|234|345|456|567|678|789))\b
1xxjACEG
例如:13685921357,13803542468
正则:\b(1\d{2}\d+(?:0246|1357|2468|3579))\b
1xxjADG
例如:13625612147,13824688369
正则:\b(1\d{2}\d+(?:147|258|369))\b


含一组连续递增数字组且结束于第7位
1xxABCD*
例如:13623454233,13856786451
正则:\b(1\d{2}(?:0123|1234|2345|3456|4567|5678|6789)\d*)\b
1xxACEG*
例如:13613572335,13824684322
正则:\b(1\d{2}(?:0246|1357|2468|3579)\d*)\b
1xxxADG*
例如:13652584417,13813698835
正则:\b(1\d{2}\d+(?:147|258|369)\d*)\b


含两组连续递增数字组
1xxABCDQRST
例如:13612343456,13845672345
正则:\b(1\d{2}(?:0123|1234|2345|3456|4567|5678|6789){2})
1xxxABCxQRS
例如:13651239456,13863457678
正则:\b(1\d{2}\d(?:012|123|234|345|456|567|678|789)\d(?:012|123|234|345|456|567|678|789))\b
1xxABCxQRSx
例如:13612374561,13834516782
正则:\b(1\d{2}(?:012|123|234|345|456|567|678|789)\d(?:012|123|234|345|456|567|678|789)\d)\b
1xxjABCQRS
例如:13647123567,13839567345
正则:\b(1\d{2}\d{2}(?:012|123|234|345|456|567|678|789)(?:012|123|234|345|456|567|678|789))\b


不含4 (单独使用貌似没什么意思,结合其他的使用)
\b[^4]{11}\b

后8位不含4
\b1\d{2}[^4]{8}\b

后8位最少含2个8(也可把8换成其他数字)
\b(1\d{2}\d*(8)\d*\2\d*)\b模式4
\b1\d{2}(\d*8){2}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*\b

后8位最少含3个8
\b(1\d{2}\d*(8)\d*\2\d*\2\d*)\b模式4
\b1\d{2}(\d*8){3}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*8\d*\b

后8位最少含4个8
\b(1\d{2}\d*(8)\d*\2\d*\2\d*\2\d*)\b模式4
\b1\d{2}(\d*8){4}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*8\d*8\d*\b

后8位最少含5个8
\b(1\d{2}\d*(8)\d*\2\d*\2\d*\2\d*\2\d*)\b模式4
\b1\d{2}(\d*8){5}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*8\d*8\d*8\d*\b

后8位最少含6个8
\b(1\d{2}\d*(8)\d*\2\d*\2\d*\2\d*\2\d*\2\d*)\b模式4
\b1\d{2}(\d*8){6}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*8\d*8\d*8\d*8\d*\b

后8位最少含7个8
\b(1\d{2}\d*(8)\d*\2\d*\2\d*\2\d*\2\d*\2\d*\2\d*)\b模式4
\b1\d{2}(\d*8){7}\d*\b   模式4
\b1\d{2}\d*8\d*8\d*8\d*8\d*8\d*8\d*8\d*\b

后8位是8个8
\b1\d{2}8{8}\b

含一组重复数字
1xxAAAAAAAA
例如:13655555555,13899999999
正则:\b(1\d{2}(\d)\2{7})\b   模式4
1xx*AAAAAAA*
例如:13615555555,13899999991
正则:\b(1\d{2}\d*(\d)\2{6}\d*)\b   模式4
1xx*AAAAAA*
例如:13613555555,13829999991
正则:\b(1\d{2}\d*(\d)\2{5}\d*)\b   模式4
1xx*AAAAA*
例如:13613255555,13829999931
正则:\b(1\d{2}\d*(\d)\2{4}\d*)\b   模式4
1xx*AAAA*
例如:13613245555,13824999931
正则:\b(1\d{2}\d*(\d)\2{3}\d*)\b   模式4
1xx*AAA*
例如:13613242555,13824799931
正则:\b(1\d{2}\d*(\d)\2{2}\d*)\b   模式4

含两组重复数字
1xxAAAAQQQQ
例如:13611115555,13833339999
正则:\b(1\d{2}(\d)\2{3}(\d)\3{3})\b   模式4
1xx*AAA*QQQ*
例如:13611155532,13833317999
正则:\b(1\d{2}\d*(\d)\2{2}\d*(\d)\3{2}\d*)\b   模式4
1xxxAAAxQQQ
例如:13621114555,13853337999
正则:\b(1\d{2}\d(\d)\2{2}\d(\d)\3{2})\b   模式4
1xxxxAAxxQQ
例如:13626116455,13851338399
正则:\b(1\d{2}\d{2}(\d)\2\d{2}(\d)\3)\b   模式4

递增+重复
1xxABCDABCD
例如:13634563456,13856785678
正则:\b(1\d{2}(0123|1234|2345|3456|4567|5678|6789)\2)\b   模式4
      \b(1\d{2}(?:0123|1234|2345|3456|4567|5678|6789)\2)\b
1xxxABCxABC
例如:13651237123,13836781678
正则:\b(1\d{2}\d(012|123|234|345|456|567|678|789)\d\2)\b   模式4
1xx*ABC*ABC*
例如:13657123123,13867831678
正则:\b(1\d{2}\d*(012|123|234|345|456|567|678|789)\d*\2)\b   模式4
1xxABABABAB
例如:13623232323,13889898989
正则:\b(1\d{2}(01|12|23|34|45|56|67|78|89)\2{3})\b   模式4
1xx*ABABAB*
例如:13652323237,13838989891
正则:\b(1\d{2}\d(01|12|23|34|45|56|67|78|89)\2{2}\d)\b   模式4
1xx*ABAB*
例如:13657232365,13867679373
正则:\b(1\d{2}\d*(01|12|23|34|45|56|67|78|89)\2\d*)\b   模式4
1xxxxABxxAB
例如:13651237923,13832891389
正则:\b(1\d{2}\d{2}(01|12|23|34|45|56|67|78|89)\d{2}\2)\b   模式4

1xxABQRABQR
例如:13623782378,13889568956
正则:\b(1\d{2}(01|12|23|34|45|56|67|78|89)(01|12|23|34|45|56|67|78|89)\2\3)\b   模式4
1xxABCDQRST
例如:13612346789,13845672345
正则:\b(1\d{2}(0123|1234|2345|3456|4567|5678|6789){2})\b   模式4
1xxQABCRABC
例如:13615672567,13871238123
正则:

…………

**** Hidden Message *****

zghwelcome 发表于 2018-1-16 16:41:37

你是到哪去找这些可用靓号啊

hnfeng 发表于 2018-1-16 16:53:12

本帖最后由 hnfeng 于 2018-1-16 17:16 编辑

你是到哪去找这些可用靓号啊
zghwelcome 发表于 2018-1-16 16:41 http://www.autoit3.cn/images/common/back.gif


号码你可以去移动联通电信的网站上找啊。

今天得闲,上面这些是自己敲出来的
感觉就是苦力活啊。
应该还有一些的,不过头晕眼花的,先发上来这些。有兴趣的朋友继续……

zpmc123 发表于 2018-1-17 11:27:46

回复 1# hnfeng


   
刚入门看的我是眼花缭乱{:face (356):}

heavenm 发表于 2018-1-17 22:38:00

本帖最后由 heavenm 于 2018-1-17 22:44 编辑

可是我认为
1xxxxAAxxQQ
例如:13626116455,13851338399
这种根本不是靓号


1X973723272
1X111666754
1X111660054
1X111666454
1X617313713
1X274773447
1X111664454
1X549544994
1X229323393
1X111663354
1X111666254
1X973773370
1X973753773
1X973733991
1X373775532
1X173443743
1X111660064
1X111666174
1X374777947
1X677444227
1X080881114
1X890202902
1X773377713
1X273311001
1X773353509
1X390033039
1X390033776
1X711313118
1X211613163
1X677336605
1X373779931
1X116647472
1X373773553
1X074242724
1X115511195
1X773344611
1X973333410
1X116011610
1X373779960


这些都是我不要的号码。只有几个被我选走了

heavenm 发表于 2018-1-18 02:06:20

本帖最后由 heavenm 于 2018-1-18 02:08 编辑

1xxABCDABCD
例如:13634563456,13856785678
正则:\b(1\d{2}(0123|1234|2345|3456|4567|5678|6789)\2)\b   模式4
      \b(1\d{2}(?:0123|1234|2345|3456|4567|5678|6789)\2)\b

精简:
宽松:(\d\d\d\d)\1
严格:\d{3}(\d\d\d\d)\1

heavenm 发表于 2018-1-18 02:34:01

你提供的所有号码!
[评分][号码] 正则
(\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
\d{3}(\d\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
\d{3}(\d\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
^\d*(\d)\1{4,}\d*$
(\d\d\d)\1
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1{4,}\d*$
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1{4,}\d*$
(\d\d)\1
(\d)\1(\d)\2
(\d\d)\1
(\d)\1(\d)\2
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
(\d\d)\1
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
(\d)\1(\d)\2
^\d*(\d)\1\1(\d)\2\2\d*$
\d{3}(\d\d\d\d)\1
\d{3}(\d\d\d\d)\1
(\d\d\d)\1
(\d\d)\1
\d{3}(\d\d\d\d)\1
(\d\d)\1
\d{3}(\d\d\d\d)\1
(\d\d)\1
(\d\d)\1
(\d\d)\1
(\d\d)\1
\d{3}(\d\d\d\d)\1
\d{3}(\d\d\d\d)\1

heavenm 发表于 2018-1-18 02:38:16

总评分,看看有没有不太合理

13612345678
13823456789
13681234567
13823456781
13685234567
13864567891
13685234562
13864567821
13685534562
13864567921
13685953452
13867442567
13685913572
13824682567
13625815712
13824688369
13802585369
13612345678
13823456789
13681234567
13842345678
13685234567
13862123456
13685623456
13864156789
13685513456
13864515678
13685953123
13867442567
13685921357
13803542468
13625612147
13824688369
13623454233
13856786451
13613572335
13824684322
13652584417
13813698835
13612343456
13845672345
13651239456
13863457678
13612374561
13834516782
13647123567
13839567345
13655555555
13899999999
13615555555
13899999991
13613555555
13829999991
13613255555
13829999931
13613245555
13824999931
13613242555
13824799931
13611115555
13833339999
13611155532
13833317999
13621114555
13853337999
13626116455
13851338399
13634563456
13856785678
13651237123
13836781678
13657123123
13867831678
13623232323
13889898989
13652323237
13838989891
13657232365
13867679373
13651237923
13832891389
13623782378
13889568956
13612346789
13845672345
13615672567
13871238123

heavenm 发表于 2018-1-18 02:42:06

代码!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <File.au3>
Dim $__file


_FileReadToArray('1.txt', $__file)
;1xxabcdabcd
For $i = 1 To $__file
        $test = _FilterNumbers($__file[$i])
        FileWriteLine('test.txt', '[' & $test & '] '&$__file[$i])
Next

;~ MsgBox(0, '靓号等级', _FilterNumbers('13802585369'))
Func _FilterNumbers($__number)
        If StringIsSpace($__number) Then Return SetError(0)
        Local $__tempText, $__level, $__consecutive


        ;----含一组连续递增数字组
        $__length = StringLen($__number)
        For $__i = 1 To $__length
                If Abs(StringMid($__number, $__i, 1) - StringMid($__number, $__i - 1, 1)) == 1 Then $__consecutive += 1
                If $__consecutive >= 3 Then $__level += 1
        Next

        ;----后八位,仅由3种以内数字组成
        $__UniqueNumber = StringRegExpReplace(StringMid($__number, 4), '(\d)(?=(?:.*?\1))', '')
        If StringLen($__UniqueNumber) <= 2 Then $__level += 5 ;纯AB
        If StringLen($__UniqueNumber) <= 3 Then $__level += 2 ;纯ABC
       
        ;----各种规则筛选
        $__level += _FormatNumber($__number, '(\d\d)\1');ABAB/AAAA
        $__level += _FormatNumber($__number, '(\d)\1(\d)\2');AABB
        $__level += _FormatNumber($__number, '(\w)\1(?!\1)(\w)\2(?!\1|\2)(\w)\3', 2);AABBCC
        $__level += _FormatNumber($__number, '^\d*(\d)\1\1(\d)\2\2\d*, 2);AAABBB
        $__level += _FormatNumber($__number, '^(\d)(\d)\1\2\1\2\1\2, 2) ;ABABAB
        $__level += _FormatNumber($__number, '^(\d)(\d)(\d)\1\2\3, 2);ABCABC
        $__level += _FormatNumber($__number, '^(\d)(\d)\2\1\2\2, 2);ABBABB
        $__level += _FormatNumber($__number, '^(\d)\1(\d)\1\1\2, 2);AABAAB
        $__level += _FormatNumber($__number, '^\d*(\d)\1{4,}\d*, 2);5-8重复
        $__level += _FormatNumber($__number, '(\d\d\d)\1', 2);ABCABC
        $__level += _FormatNumber($__number, '\d{3}(\d\d\d\d)\1', 5);ABCDABCD
        Return $__level
EndFunc   ;==>_FilterNumbers


Func _FormatNumber($__str, $__regular, $__level = 1)
        Local $__debug = 1
        If StringRegExp($__str, $__regular) Then
                If $__debug == 1 Then ConsoleWrite('[' & $__level & '][' & $__str & '] ' & $__regular & @CRLF);[等级] 规则
                Return $__level
        EndIf
        Return 0
EndFunc   ;==>_FormatNumber

heavenm 发表于 2018-1-18 02:48:46

本帖最后由 heavenm 于 2018-1-18 02:54 编辑

13867679373
这个号码按照我的标准 最高3分,BUG

我现在用的号码
1XX6767123X 不含4,感觉不是特别喜欢

主要因为我有一个比较好的号码,不过不是网上找到的,是特殊渠道
1XXABABAABB,目前网上筛选的号码,几万个,都没选到这种靓号,看来渠道很重要。网上放不出来这种靓号估计
{:face (197):} 每次报号码人家都问我是不是开玩笑!

heavenm 发表于 2018-1-18 03:02:59

修正版,这个号码就判断一分好了#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <File.au3>
Dim $__file


;~ _FileReadToArray('1.txt', $__file)
;~ For $i = 1 To $__file
;~         $test = _FilterNumbers($__file[$i])
;~         FileWriteLine('test.txt', '[' & $test & '] '&$__file[$i])
;~ Next

MsgBox(0, '靓号等级', _FilterNumbers('13867679373'))
Func _FilterNumbers($__number)
        If StringIsSpace($__number) Then Return SetError(0)
        Local $__tempText, $__level, $__consecutive


        ;----含一组连续递增数字组
        $__length = StringLen($__number)
        For $__i = 1 To $__length
                If StringMid($__number, $__i, 1) == StringMid($__number, $__i+2, 1) Or StringMid($__number, $__i, 1) == StringMid($__number, $__i-2, 1) Then        ContinueLoop
                If Abs(StringMid($__number, $__i, 1) - StringMid($__number, $__i - 1, 1)) == 1 Then $__consecutive += 1
                If $__consecutive >= 3 Then         $__level += 1
        Next
;~         ConsoleWrite('[' & $__level & '][' & $__number & '] 连续递增' & @CRLF);[等级] 规则

        ;----后八位,仅由3种以内数字组成
        $__UniqueNumber = StringRegExpReplace(StringMid($__number, 4), '(\d)(?=(?:.*?\1))', '')
        If StringLen($__UniqueNumber) <= 2 Then $__level += 5 ;纯AB
        If StringLen($__UniqueNumber) <= 3 Then $__level += 2 ;纯ABC
       
        ;----各种规则筛选
        $__level += _FormatNumber($__number, '(\d\d)\1');ABAB/AAAA
        $__level += _FormatNumber($__number, '(\d)\1(\d)\2');AABB
        $__level += _FormatNumber($__number, '(\w)\1(?!\1)(\w)\2(?!\1|\2)(\w)\3', 2);AABBCC
        $__level += _FormatNumber($__number, '^\d*(\d)\1\1(\d)\2\2\d*, 2);AAABBB
        $__level += _FormatNumber($__number, '^(\d)(\d)\1\2\1\2\1\2, 2) ;ABABAB
        $__level += _FormatNumber($__number, '^(\d)(\d)(\d)\1\2\3, 2);ABCABC
        $__level += _FormatNumber($__number, '^(\d)(\d)\2\1\2\2, 2);ABBABB
        $__level += _FormatNumber($__number, '^(\d)\1(\d)\1\1\2, 2);AABAAB
        $__level += _FormatNumber($__number, '^\d*(\d)\1{4,}\d*, 2);5-8重复
        $__level += _FormatNumber($__number, '(\d\d\d)\1', 2);ABCABC
        $__level += _FormatNumber($__number, '\d{3}(\d\d\d\d)\1', 5);ABCDABCD
        Return $__level
EndFunc   ;==>_FilterNumbers


Func _FormatNumber($__str, $__regular, $__level = 1)
        Local $__debug = 1
        If StringRegExp($__str, $__regular) Then
                If $__debug == 1 Then ConsoleWrite('[' & $__level & '][' & $__str & '] ' & $__regular & @CRLF);[等级] 规则
                Return $__level
        EndIf
        Return 0
EndFunc   ;==>_FormatNumber

heavenm 发表于 2018-1-18 03:05:27

本帖最后由 heavenm 于 2018-1-18 03:32 编辑

这个连号规则好复杂啊!
N多BUG

heavenm 发表于 2018-1-18 03:53:45

连续递增的修正了,这下应该什么问题了        $__length = StringLen($__number)
        For $__i = 1 To $__length
                If StringMid($__number, $__i, 1) == StringMid($__number, $__i + 2, 1) Or StringMid($__number, $__i, 1) == StringMid($__number, $__i - 2, 1) Then ContinueLoop
                $__diff = StringMid($__number, $__i, 1) - StringMid($__number, $__i - 1, 1);与下一位数字差异值
                If Abs($__diff) == 1 Then $__consecutive += $__diff
                If $__consecutive >= 3 Then
                        $__level += 1
                        If Abs($__consecutive + 1) <> Abs($__consecutive + $__diff) Then
                                $__consecutive = 0
                        EndIf
                EndIf
        Next这个连续递增这么复杂,写完,我自己也迷糊了

heavenm 发表于 2018-1-18 04:24:29

不改了!脑壳疼!~~~#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <File.au3>
Dim $__file


;~ _FileReadToArray('1.txt', $__file)
;~ For $i = 1 To $__file
;~         $test = _FilterNumbers($__file[$i])
;~         FileWriteLine('test.txt', '[' & $test & '] '&$__file[$i])
;~ Next

MsgBox(0, '靓号等级', _FilterNumbers('13867679373'))
Func _FilterNumbers($__number)
        If StringIsSpace($__number) Then Return SetError(0)
        Local $__tempText, $__level, $__consecutive, $__diff


        ;----含一组连续递增数字组
        $__length = StringLen($__number);数字长度
        For $__i = 1 To $__length
                If $__i == 1 Then ContinueLoop
                $__diff = StringMid($__number, $__i, 1) - StringMid($__number, $__i - 1, 1);与下一位数字差异值
                If Abs($__diff) == 1 Then
;~                         MsgBox(0, $__i, StringMid($__number, $__i, 1) & '-' & StringMid($__number, $__i - 1, 1))
                        $__consecutive += $__diff;如果差距为1则增加连续数

                       
                        If $__consecutive >= 2 Then;连续2次等于三连
;~                                 MsgBox(0, $__i, StringMid($__number, $__i, 1) & '-' & StringMid($__number, $__i - 1, 1))
                                $__level += 1
                                If Abs($__consecutive + 1) <> Abs($__consecutive + $__diff) Then;防止出现正逆,两种混合数字误判,如6767
                                       
                                        $__consecutive = 0
                                EndIf
                        EndIf
                EndIf
        Next
        ConsoleWrite('[' & $__level & '][' & $__number & '] 连续递增' & @CRLF);[等级] 规则

        ;----后八位,仅由3种以内数字组成
        $__UniqueNumber = StringRegExpReplace(StringMid($__number, 4), '(\d)(?=(?:.*?\1))', '')
        If StringLen($__UniqueNumber) <= 2 Then $__level += 5 ;纯AB
        If StringLen($__UniqueNumber) <= 3 Then $__level += 2 ;纯ABC
       
        ;----各种规则筛选
        $__level += _FormatNumber($__number, '(\d\d)\1');ABAB/AAAA
        $__level += _FormatNumber($__number, '(\d)\1(\d)\2');AABB
        $__level += _FormatNumber($__number, '(\w)\1(?!\1)(\w)\2(?!\1|\2)(\w)\3', 2);AABBCC
        $__level += _FormatNumber($__number, '^\d*(\d)\1\1(\d)\2\2\d*, 2);AAABBB
        $__level += _FormatNumber($__number, '^(\d)(\d)\1\2\1\2\1\2, 2) ;ABABAB
        $__level += _FormatNumber($__number, '^(\d)(\d)(\d)\1\2\3, 2);ABCABC
        $__level += _FormatNumber($__number, '^(\d)(\d)\2\1\2\2, 2);ABBABB
        $__level += _FormatNumber($__number, '^(\d)\1(\d)\1\1\2, 2);AABAAB
        $__level += _FormatNumber($__number, '^\d*(\d)\1{4,}\d*, 2);5-8重复
        $__level += _FormatNumber($__number, '(\d\d\d)\1', 2);ABCABC
        $__level += _FormatNumber($__number, '\d{3}(\d\d\d\d)\1', 5);ABCDABCD
        Return $__level
EndFunc   ;==>_FilterNumbers


Func _FormatNumber($__str, $__regular, $__level = 1)
        Local $__debug = 1
        If StringRegExp($__str, $__regular) Then
                If $__debug == 1 Then ConsoleWrite('[' & $__level & '][' & $__str & '] ' & $__regular & @CRLF);[等级] 规则
                Return $__level
        EndIf
        Return 0
EndFunc   ;==>_FormatNumber

hnfeng 发表于 2018-1-18 08:54:05

回复 14# heavenm


    赞一个
好高深啊
页: [1] 2
查看完整版本: 【分享、征集、请教】手机靓号正则表达式