Regular Expression-difference between PHP regular [sS] And. * And (...) Capturing

Source: Internet
Author: User
Tags php regular expression
PHP regular expression. If you want to match the following text, run the xxx certificate, run the 0 certificate, and run the 00 certificate. {Code...} PHP regular expression. Match the following text to run the certificate, run the xxx certificate, run the 0 certificate, and run the 00 certificate.

Php$ Reg = '/do (...) {0, 14} Certificate/'; # do 0 certificate this cannot match? Strange things!

Reply content:

PHP regular expression. If you want to match the following text, run the xxx certificate, run the 0 certificate, and run the 00 certificate.

Php$ Reg = '/do (...) {0, 14} Certificate/'; # do 0 certificate this cannot match? Strange things!

Note: The symbol. represents any character. Here you use three symbols (.), in addition, you use {0, 4}, indicating (...) it appears 0 to 14 times at most, that is to say, the character after it appears is a multiple of three. Therefore, 0 certificates cannot be matched.

You can try this:$ Reg = '/run (.) {} Certificate /';

If there is no limit on the number of words between the domain name and the certificate, you can simply do it like this:$ Reg = '/office (. *) Certificate /'

Agree to go upstairs and run the [^ certificate] {0, 14} Certificate/sentence. Remember that there is also a concept of laziness and greedy matching...

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.