Number level definition, ask for help to tell the rule how to write?

convert the level of an inner-table number according to the format. The format is defined as follows (matching the last digits):
Type 1 AAAAA (5 hyphens) ABCDEF
Type 2 AAAA (4 hyphens, excluding 4) ABCDE
Class 3 AAA (3 hyphens, excluding 4) ABCD
Class 4
Class 5, 444 WWXXYY AAAAB
Type 6 AAAB AABB ABAB
other types

the number is fixed line, 11 digits long, the front is the area code, the last 7 digits are the number, the matching rule is the last few digits, for example, AAAAA can be 05311522222
help boss told me how to write the rule, thank you very much

May.28,2022

first category (last 5 digits) AAAAA

"05311500000".matches("[0-9]{6}(0{5}|1{5})")

Category 6 (last 4) AAAB AABB ABAB

"05311531110".matches("[0-9]{7}(0{3}[^0]|1{3}[^1]|2{3}[^2])") 
"05311531100".matches("[0-9]{7}(0{2}[^0]{2}|1{2}[^1]{2})")
"05311531010".matches("[0-9]{7}((0[^0]){2}|(1[^1]){2})")

Let me give you two chestnuts, and you have to write the rest by yourself. Here, you have to answer the questions, not ask the answers.

//5
Pattern.matches("\\d{4}.*?(\\d)\\1{4}.*?","05311522222")

//44
Pattern.matches("\\d{4}.*?([0-3,5-9])\\1{3}.*?","05311533332")

 // AAAAA5 ABCDEF 
 "^\\d{4}\\d{2}(\\d)\\1{4}$"

 // AAAA44 ABCDE  
 "^\\d{4}\\d{2}(\\d)(?!\\1)([0-35-9])\\2{3}$"
 ...

 // 
 "^\\d{4}\\d{2}\\d4{4}$"

search for keywords, regular numbers, a lot of articles.

for example: https://www.cnblogs.com/hdl21...

Menu