Code for determining the number type of the Regular Expression

Source: Internet
Author: User

Nickname Detection: It can mainly detect Connection Numbers (12345, 65432), AABB, mobile phone number, date number (birthday number, year number), abbcabb number, and replay numbers with more than three digits. More types of number detection can be modified according to the following expression.

'Match the 6-digit 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 downgrading
RegEx. pattern = "(? : 9 (? = 8) | 8 (? = 7) | 7 (? = 6) | 6 (? = 5) | 5 (? = 4) | 4 (? = 3) | 3 (? = 2) | 2 (? = 1) | 1 (? = 0) {5} \ D"

'Match 6 bits for ascending or descending order
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

Matches three or more repeated numbers.
([\ D]) \ 1 {2 ,}

Number that matches the 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
(13 [0-9] | 15 [0-9] | 18 [0-9]) ([\ D] {2, 4}) {2}

Match the 33111 type
([\ D]) \ 1 {1,} ([\ D]) \ 2 {2 ,}

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

Matching 22334,123355 type
([\ D]) \ 1 {1,} ([\ D]) \ 2 {1 ,}

The above regular expressions are all debugged in mtracer 2.0 and passed in practical applications. You are welcome to express your views and share your own technologies and experiences.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.