How to write a regular ID number that matches 15 digits, 18 digits, and the last character is a letter?

guys, I want to use a regular expression to match 15-bit, 18-bit, and alphabetic ID numbers in a bunch of strings. The pile of strings is as follows:

| _ Potentially risky methods: TRACE
| _ http-server-header: / 2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45
| _ http-title: 403 Forbidden
88/tcp filtered kerberos-sec
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
389/tcp filtered ldap
440923195906209416 445/tcp filtered microsoft-ds
Device type: general purpose | media device | router | specialized | WAP 440923195906207971
Running (JUST GUESSING): Microsoft Windows 2003 | XP | 2000 (92), Microsoft embedde
d (88), Linksys embedded (87), AVtech embedded () Apple embedded (85%)
OS CPE: cpe:/o:microsoft:windows_server_2003::sp1 cpe:/o:microsoft:windows_serve
r_2003::sp2 cpe:/o:micr 440923195906206717 osoft:windows_xp::sp3 cpe::airport_extreme cpe:/o
: microsoft:windows_2000::sp4:server
Aggressive OS guesses: Microsoft Windows Server 2003 SP1 or SP2 (92%), Microsoft
Window 44092319590620907x s XP SP3 or
irmware 3.1) (88%), Linksys BEFSR41 EtherFast router (87%), Microsoft Windows Se
rver 2003 SP2 (87%), AVtech Room Alert 26W environmental monitor (85%), Microsof
t Windows XP SP2 or SP3 (85%), Apple AirPort Extreme WAP (85%), Microsoft Window
s 2000 Server SP4 or Windows XP Professional SP3 (85%), Microsoft Windows 2000 S
P4 (85%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 15 hops
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

it is known that there is a rule that matches 18 bits:
[1-9] d {5} (?: 19 | 20) dd (?: 0 [1-9] | 1 [012]) (?: 0 [1-9] | [12] d | 3 [01]) d {4}
will match the ID card:
440923195906209416
440923195906207971
440923195906207971

ask all of you to show me how to change this regular expression! Thank you!

ID card numbers above PS: are randomly generated ID numbers, not real ID numbers, please be familiar with them.

PS: I want to use python to implement


18 bits

(?:1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5])\d{4}(?:1[89]|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}(?:\d|[xX])

15 bits

(?:1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5])\d{4}\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}

/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])(\d{3}[Xx])$)$/

the last ID card should only have X bar

normal ID card matching is / ^ (^ [1-9]\ d {7} ((0\ d) | (1 [0-2])) (([0 | 1 | 2]\ d) | 3 [0-1])\ d {3} $) | (^ [1-9]\ d {5} [1-9]\ d {3} (0\ d) | (1 [0-2])) (([0 | 1 | 2]\ d) | 3 [0-1] \ d {4}) |\ d {3} [Xx]) $) $/


/ ^ (^ [1-9] d {7} ((0d) | (1 [0-2])) (([0 | 1 | 2] d) | 3 [0-1]) d {3} $) | (^ [1-9]\ d {5} [1-9]\ d {3} (0\ d) | (1 [0-2])) (([0 | 1 | 2]\ d) | 3 [0-1]) ((\ d {4} } [Xx]) $) $/


introduction

xxxxxx yyyy MM dd 3750 18 bits

xxxxxx yy MM dd 750 15 bits

region: [1-9] d {5}

the first two places of the year: (18 | 19 | ([23] d)) 1800-2399

) The last two digits of

year: d {2}

month: ((0 [1-9]) | (10 | 11 | 12)

days: ((0-2) | 10 | 20 | 30 | 31) 29 + cannot be prohibited in leap years

three-digit sequence code: d {3}

two-digit sequence code: d {2}

check code: [0-9Xx]

regular expression

Eighteen digits: ^ [1-9]\ d {5} (18 | 19 | ([23]\ d))\ d {2} ((0 [1-9])) | (10 | 11 | 12)) (([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {3} [0-9Xx] $

15 digits: ^ [1-9]\ d {5}\ d {2} ((0 [1-9]) | (10 | 11 | 12)) (([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {2} $

Total:

(^ [1-9]\ d {5} (18 | 19 | ([23]\ d))\ d {2} ((0 [1-9])) | (10 | 11 | 12)) (([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {3} [0-9Xx] $) | (^ [1-9]\ d {5}\ d {2} ((0 [1-9])) | (10 | 11 | 12)) (([0])


you can try this. It works well when I try it locally.

<input type="text" id="inputVal" >
<div id="test"></div>
let test= document.getElementById("test");
test.addEventListener("click", function () {
   let input = document.getElementById("inputVal").value;
   let reg = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
   if (!reg.test(input)) {
     alert("");
   } else {
     alert("OK!");
   }
});    

try this according to the ID card coding format:
18 bits:

(?<n1>[1,6][1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|71|8[1-2])\d{4}(?<n1>19|20)\d{2}(?<n3>0[1,3,5,7,8](0[1-9]|[1,2]\d|3[0,1])|02(0[1-9]|[1-2]\d)|0[4,6,9](0[1-9]|[1,2]\d|30)|1[0,2](0[1-9]|[1,2]\d|3[0,1])|11(0[1-9]|[1,2]\d|30))\d{3}(?<n4>\d|[x,X])

15 bits:

(?<n1>[1,6][1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|71|8[1-2])\d{6}(?<n3>0[1,3,5,7,8](0[1-9]|[1,2]\d|3[0,1])|02(0[1-9]|[1-2]\d)|0[4,6,9](0[1-9]|[1,2]\d|30)|1[0,2](0[1-9]|[1,2]\d|3[0,1])|11(0[1-9]|[1,2]\d|30))\d{3}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be7220-3183c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be7220-3183c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?