ID number to determine whether proper use is regular, Java and js used in a regular way big bad not bad, here is the Java regular judging by the ID number is correct
* * / @Test public void CardID () { System.out.println ( "ID number:"); String S = "61011319780908211x"; String REGEX = "\\ {15} D | D \\. 17} {[ DXX \\] "; // IF (s.matches (REGEX)) { System.out.println (" correct format "); } the else { System.out.println (" format error "); } }
js determined by regular identification numbers written as follows:
var cardId = / ^ [1-9] [0-9] {5} (19 | 20) [0-9] {2} ((01 | 03 | 05 | 07 | 08 | 10 | 12) (0 [ 1-9] | [1-2] [0-9 ] | 31) | (04 | 06 | 09 | 11) (0 [1-9] | [1-2] [0-9] | 30) | 02 (0 [1-9] | [1-2] [0-9])) [0-9]. 3} {([0-9] | X | X-) $ /; var = AA "41110920090908900x"; IF (cardId.test (AA)) { the console.log ( "correct") } {the else the console.log ( "incorrect format") }
Regular expressions commonly used special