手机靓号规则很多如连号、尾号重复等等, 但很少有完整说明的材料。因工作需要,我也做过一些学习,查了不少资料。 现在整理下规则,供大家学习使用。
手机靓号正则表达式
手机靓号正则 ABC+ = 1234或12345… AAAA+ = 1111或11111…
AAAA+ / / ABC+DDD+ / /AA+BBB+//AABBCC//ABABAB
AAAA+ (\d)\1{3,} //如果想调3A+改{3,}改成{2,},想固定3A的话把{2,}的{,}号去掉 (1111+)
ABC+DDD+ (?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2,}\d(\d)\1{1,} (123+555+)
AA+BBB+ ([\d])\1{1,}([\d])\2{2,} (11222/111222)
AABBCC ([\d])\1{1}([\d])\2{1}([\d])\3{1} (115566)
ABABAB (\d)((?!\1)\d)\1\2\1\2 (121212)
ABCDABCD (12341234)
(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\d(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\d
ABCABC (123123)
(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\d(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\d
ABC*ABC (1235123)
(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\d[\d](?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\d // 如果两个*的话在中间[\d]这个位置加一个[\d]
ABCD+ (?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3,}\d
+DCBA (?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){3,}\d
AAA 结尾 \d{7}([0-9])(?!\1)([0-9])\2{2}
AABB 结尾 \d{6}([0-9])(?!\1)([0-9])\2(?!\2)([0-9])\3
AA 结尾 \d{8}([0-9])(?!\1)([0-9])\2{1}
ABAB 结尾 \d{7}([0-9])(?!\1)([0-9])\1\2
ABC 结尾 \d{7}([0-9]012|[0]123|[1]234|[2]345|[3]456|[4]567|[5]678|[^6]789)
CBA 结尾 \d{7}([0-9]987|[9]876|[8]765|[7]654|[6]543|[5]432|[4]321|[^3]210)
“ab** ab**” “\d{3}(\d{2})(?!\1)(\d{2})\1(\d{2})” “如 2365 2374”
“**ab **ab” “\d{5}(\d{2})(?!\1)(\d{2})\1” “结尾如 2356 8756”
“不带 4 和 7” “(0|1|2|3|5|6|8|9){11}” “不带 4 和 7”
“不带 4 或 7” “(0|1|2|3|5|6|8|9){11}” “手机号码不带 4 或 7”
“号段不带四,后四位带四” “1\d{2}[012356789]{4}(4\d{3}|\d4\d\d|\d\d4\d|\d{3}4)” “号段不带四,后四位带四”
“号段带四,后四位不带四” “1\d{2}(4\d{3}|\d4\d\d|\d\d4\d|\d{3}4)[012356789]{4}” “号段带四,后四位不带四”
“六拖二” “\d{2}([0-9])(?!\1)([0-9])\2{5}(?!\2)([0-9])\3” “如 33333322”
“六拖一” “\d{3}([0-9])(?!\1)([0-9])\2{5}(?!\2)([0-9])” “如 5555554”
“年份类” “\d{7}((19[5-9][0-9])|(20[0-1][0-9]))” “筛选年份特征的号码”
“生日类” “\d{7}(?:0[13578]|1[02])(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)(?:0[1-9]|[12]\d|30)|02(?:0[1-9]|1\d|2[0-8])” “筛选生日特征的号码”
“四拖二” “\d{4}([0-9])(?!\1)([0-9])\2{3}(?!\2)([0-9])\3” “结尾如 777744”
“四拖一” “\d{5}([0-9])(?!\1)([0-9])\2{3}(?!\2)([0-9])” “结尾如 77774”
“五拖二” “\d{3}([0-9])(?!\1)([0-9])\2{4}(?!\2)([0-9])\3” “如 4444422”
“五拖一” “\d{4}([0-9])(?!\1)([0-9])\2{4}(?!\2)([0-9])” “结尾如 777774”
“以 88 结尾” “\d{9}(88)” “以 88 结尾”
22.10.10
"*AAA*" 正则表达式:"\\d([0-9])(?!\\1)([0-9])\\2{2}\\d" "如 67772"
"*AAAA*" 正则表达式:"\\d([0-9])(?!\\1)([0-9])\\2{3}\\d" "如 355553"
"A2B2B2A2" 正则表达式:"\\d{3}(\\d{2})(?!\\1)(\\d{2})\\2\\1" "如 33555533"
"A3B3" 正则表达式:"\\d{5}(\\d{3})\\1" "结尾如 555777"
"*AAAAA*" 正则表达式:"\\d([0-9])(?!\\1)([0-9])\\2{4}\\d" "如 4666662"
"7 拖 1" 正则表达式:"\\d{2}([0-9])(?!\\1)([0-9])\\2{6}(?!\\2)([0-9])" use="no" bz="如 33333335"
"**ab **ab" 正则表达式:"\\d{5}(\\d{2})(?!\\1)(\\d{2})\\1" "结尾如 2356 8756"
"7 拖二" 正则表达式:"\\d{1}([0-9])(?!\\1)([0-9])\\2{6}(?!\\2)([0-9])\\3" "如 44444442"
"AA" 正则表达式:"\\d{8}([0-9])(?!\\1)([0-9])\\2{1}" "结尾双连"
"AAA" 正则表达式:"\\d{7}([0-9])(?!\\1)([0-9])\\2{2}" "结尾三连"
"AAAA" 正则表达式:"\\d{6}([0-9])(?!\\1)([0-9])\\2{3}" "4 连炸弹"
"8 拖一" 正则表达式:"\\d{1}([0-9])(?!\\1)([0-9])\\2{7}(?!\\2)([0-9])" "如 666666669"
"AAAAA" 正则表达式:"\\d{6}([0-9])\\1{4}" "5 连炸弹"
"AAAAAA" 正则表达式:"\\d{5}([0-9])\\1{5}" "6 连"
"AAAB" 正则表达式:"\\d{6}([0-9])(?!\\1)([0-9])\\2{2}(?!\\2)([0-9])" "结尾如 7778"
"AABB" 正则表达式:"\\d{6}([0-9])(?!\\1)([0-9])\\2(?!\\2)([0-9])\\3" "结尾如 7788"
"AABBCC" 正则表达式:"\\d{4}([0-9])(?!\\1)([0-9])\\2(?!\\2)([0-9])\\3(?!\\3)([0-9])\\4" "结尾如 335577"
"AABBCCDD" 正则表达式:"\\d{3}([0-9])\\1([0-9])\\2([0-9])\\3([0-9])\\4" "如 22443311"
"AABBCCDDEE" 正则表达式:"\\d{3}([0-9])\\1([0-9])\\2([0-9])\\3([0-9])\\4" "如 2244668811"
"ab** ab**" 正则表达式:"\\d{3}(\\d{2})(?!\\1)(\\d{2})\\1(\\d{2})" "如 2365 2374"
"ABAB" 正则表达式:"\\d{7}([0-9])(?!\\1)([0-9])\\1\\2" "结尾如 2323"
"ABBA" 正则表达式:"\\d{7}([0-9])(?!\\1)([0-9])\\2\\1" "结尾如 7887"
"ABBABB" 正则表达式:"\\d{5}([0-9])(?!\\1)([0-9])\\2\\1\\2\\2" "结尾如 233233"
"ABC" 正则表达式:"\\d{7}([0-9]012|[^0]123|[^1]234|[^2]345|[^3]456|[^4]567|[^5]678|[^6]789)" "结尾三连"
"ABCABC" 正则表达式:"\\d{5}(\\d{3})\\1" "结尾如 345345"
"ABCD" 正则表达式:"\\d{6}([0-9]0123|[^0]1234|[^1]2345|[^2]3456|[^3]4567|[^4]5678|[^5]6789)" "4 连升"
"ABCDABCD" 正则表达式:"\\d{3}(\\d{4})\\1" "如 25672567"
"ABCDE" 正则表达式:"\\d{6}(01234|12345|23456|34567|45678|56789)" "5 连升"
"DCBA" 正则表达式:"\\d{6}([0-9]9876|[^9]8765|[^8]7654|[^7]6543|[^6]5432|[^5]5678|[^4]3210)" "4 连降"
"EDCBA" 正则表达式:"\\d{6}(43210|54321|65432|76543|87654|98765)" "5 连降序"
"不带 4 和 7" 正则表达式:"(0|1|2|3|5|6|8|9){11}" "不带 4 和 7"
"不带 4 或 7" 正则表达式:"(0|1|2|3|5|6|8|9){11}" "手机号码不带 4 或 7"
"号段不带四,后四位带四" 正则表达式:"1\\d{2}[012356789]{4}(4\\d{3}|\\d4\\d\\d|\\d\\d4\\d|\\d{3}4)" "号段不带四,后四位带四"
"号段带四,后四位不带四" 正则表达式:"1\\d{2}(4\\d{3}|\\d4\\d\\d|\\d\\d4\\d|\\d{3}4)[012356789]{4}" "号段带四,后四位不带四"
"六拖二" 正则表达式:"\\d{2}([0-9])(?!\\1)([0-9])\\2{5}(?!\\2)([0-9])\\3" "如 33333322"
"六拖一" 正则表达式:"\\d{3}([0-9])(?!\\1)([0-9])\\2{5}(?!\\2)([0-9])" "如 5555554"
"年份类" 正则表达式:"\\d{7}((19[5-9][0-9])|(20[0-1][0-9]))" "筛选年份特征的号码"
"生日类" 正则表达式:"\\d{7}(?:0[13578]|1[02])(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)(?:0[1-9]|[12]\\d|30)|02(?:0[1-9]|1\\d|2[0-8])" "筛选生日特征的号码"
"四拖二" 正则表达式:"\\d{4}([0-9])(?!\\1)([0-9])\\2{3}(?!\\2)([0-9])\\3" "结尾如 777744"
"四拖一" 正则表达式:"\\d{5}([0-9])(?!\\1)([0-9])\\2{3}(?!\\2)([0-9])" "结尾如 77774"
"五拖二" 正则表达式:"\\d{3}([0-9])(?!\\1)([0-9])\\2{4}(?!\\2)([0-9])\\3" "如 4444422"
"五拖一" 正则表达式:"\\d{4}([0-9])(?!\\1)([0-9])\\2{4}(?!\\2)([0-9])" "结尾如 777774"
"以 88 结尾" 正则表达式:"\\d{9}(88)" "以 88 结尾"
"最后一位带四" 正则表达式:"\\d{10}(4)" "最后一位带四"
以上正则表达式,非常通用, 做些变化后能适用于所有编程语言。欢迎取用!
序号 | 规则 | 正则表达式 |
---|---|---|
01 | 尾数不是4的 | \d+[^4]$ |
02 | 不能含4的 | [0-35-9]{11} |
03 | AABB尾号 | ^\d+(\d)(?!\1)(\d)\2((?!\2)\d)\3$ |
04 | AAA尾号 | ^\d+(\d)(?!\1)(\d)\2{2}$ |
05 | AAA非尾号 | ^(\d)+(?!\1)(\d)\2{2}(?!\2)\d+$ |
06 | AAA不限位 | ^(\d)+(?!\1)(\d)\2{2}(?!\2)\d*$ |
07 | AAAB尾号 | (\d)+(?!\1)(\d)\2{2}((?!\2)\d)$ |
08 | ABAB尾号 | ^\d{7}(\d)((?!\1)\d)\1\2$ |
09 | AABA尾号 | ^\d{7}(\d)\1((?!\1)\d)\1$ |
10 | ABAA尾号 | ^\d{7}(\d)((?!\1)\d)\1{2}$ |
11 | ABBA尾号 | ^\d{7}(\d)((?!\1)\d)\2\1$ |
12 | ABCC尾号 | ^\d{7}(\d)((?!\1)\d)((?!\1|\2)\d)\3$ |
13 | AABBB不限位 | (\d)\1{1,}(\d)\2{2,} |
14 | ABBABB,AABAAB不限位 | ((\d)\2*(?!\2)(\d)\3*)\1+ |
15 | AABB,AAABB,AABBB不限位 | (\d)\1{1,}(\d)\2{1,} |
16 | 3位以上的重复数字 | (\d)\1{2,} |
17 | 6位顺增 | (?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\d |
18 | 3位以上顺增 | (?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3,}+\d |
19 | 6位顺降 | (?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){5}\d |
20 | 6位顺增或顺降 | (?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}|(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){5})\d |
21 | 4-9位连续的数字 | (?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3,}|(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){3,})\d |
22 | 日期类型的数字 | (19|20)\d{2}(1[0-2]|0?[1-9])(31|2[0-9]|1[0-9]|0?[0-9]) |
ABABCDCD()11223344 (\d)((?!\1)\d)\\1\\2(\d)(\d)\\3\\4(\d)((?!\1)\d)\\1\\2(\d)(\d)\\3\\4
全部单数 /^(1|3|5|7|9){11}$/m
发表评论