Returns the phpisbn regular expression. The expected results are as follows,
When the number of digits entered by the user is 13, it is determined that the first to fourth digits start with 9787. the last eight digits contain non-numbers, and the last digit can be a number or a letter.
That is, when the isbn number entered by the user meets the rules I want, the matching result is 0 and the matching result is 1 if it does not meet the rules I want.
I can't write it a few times.
$ Str = "9777123456789 ";
$ Pattern_url = "/\ B ^ (! (9787) \ w {7} \ B $/is ";
If (preg_match ($ pattern_url, $ str) {// if the matching result is 1, it is not included. if it is 0, it contains 97871111234567
Echo "does not include 9787! "; // The expected effect. if it matches a string of 13 digits but is not a string of 9787 headers, an error is returned.
} Else {
Echo "contains 9787! ";
}
?>
Reply to discussion (solution)
Judge that the first to fourth digits start with 9787, the last eight digits contain non-numbers, and the last digit can be a number or a letter.
--------------
Is there a problem with your sentence? There are numbers in the middle.
#9787 \ d {8} [a-z0-9] # I
This is a matching rule. None of the above