Regular expression-PHP regular expression match preg_match uppercase U lowercase u

Source: Internet
Author: User
Tags php regular expression
We found a strange phenomenon. if u is added, the results are different, and the results of uppercase and lowercase U are different. We found a strange phenomenon. if u is added, the results are different, and the results of uppercase and lowercase U are different.

Reply content:

We found a strange phenomenon. if u is added, the results are different, and the results of uppercase and lowercase U are different.


U (PCRE_UTF8)

This modifier opens an additional feature that is incompatible with perl. The pattern string is considered to be UTF-8. This modifier is available for php 4.1.0 or later in unix and php 4.2.3 In win32. Php 4.3.5 start to check the validity of the UTF-8 mode

U (PCRE_UNGREEDY)

This modifier reverses the "greedy" pattern of quantifiers. The quantifiers are non-greedy by default, followed by quantifiers? To make it greedy. This is incompatible with perl. It can also be set using the in-mode modifier (? U), or mark it with a question mark (such as. *?) after the quantifiers .*?).

Pattern modifier


U is in the lazy mode by default. if not added, the greedy mode is used by default.


One is the greedy mode, and the other is not the greedy mode. if the greedy mode is used, all results will be output. You can refer to the php help document.

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.