Returns the phpisbn regular expression.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.