String regularExpression = ^1-9d5181920d201-91011120-21-910203031d30-9Xx$ + ^1-9d5d201-91011120-21-910203031d3$;
This regular expression is used to validate Chinese ID card numbers.
The first part of the regular expression, "(^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)", matches the 18-digit ID card number format.
- The first digit must be a number between 1-9.
- The next 5 digits represent the birthplace code.
- The next 4 digits represent the birth year.
- The next 2 digits represent the birth month.
- The next 2 digits represent the birth day.
- The next 3 digits represent the sequence code.
- The last digit can be either a number between 0-9 or the letter X (or x) to represent a check code.
The second part of the regular expression, "(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)", matches the 15-digit ID card number format.
- The first digit must be a number between 1-9.
- The next 5 digits represent the birthplace code.
- The next 2 digits represent the birth year.
- The next 2 digits represent the birth month.
- The next 2 digits represent the birth day.
- The last 3 digits represent the sequence code.
Overall, this regular expression ensures that the ID card number provided follows the correct format and contains valid birthplace, birth date, and sequence code information
原文地址: https://www.cveoy.top/t/topic/gDI5 著作权归作者所有。请勿转载和采集!