Regular expression number type judgment code

Time:2021-4-17

Beautiful number detection: mainly can detect serial number (positive connection 12345, reverse connection 65432), AABB number, mobile phone number, date number (birthday number, year number), abbcabb number, more than 3 repeated numbers. More type number detection can be modified according to the following expression.

‘match 6-bit forward increment
regex.Pattern = “(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\d”

‘match 6-bit down
regex.Pattern = “(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){5}\d”

‘match 6-digit up or down
regex.Pattern = “(?:(?: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”

Match 4-9 consecutive digits
(?:(?: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

Match more than 3 repeated digits
([\d])\1{2,}

Number matching date type
(19|20)[\d]{2}(1[0-2]|0?[1-9])(31|2[0-9]|1[0-9]|0?[0-9])

Mobile phone number class
(13[0-9]|15[0-9]|18[0-9])([\d]{2,4}){2}

Matching 33111
([\d])\1{1,}([\d])\2{2,}

Match type 5331533
(([\d]){1,}([\d]){1,})\1{1,}

Matching 22334123355
([\d])\1{1,}([\d])\2{1,}

The above rules are debugged in MTracer 2 and passed in practical application. You are welcome to express your views and share your skills and experiences.