Meaning of preg_match isU in php

Source: Internet
Author: User
Tags regular expression

What does the/(. *)/isU and "isU" parameter after the regular expression mean?
This is the modifier in the regular expression.
I is used to search for uppercase and lowercase letters at the same time,
S indicates that the dot (.) matches all characters, including line breaks. If s is not set, the line breaks are not included.
U reverses the value of the matching quantity so that it is not the default repetition, but becomes behind "?" To be repeated.

Example

In the regular expression syntax compatible with preg_match, B represents the word boundary.
So: which of the following is OK ???

The code is as follows: Copy code

$ A = "test, admin, abc ";

$ B = "te ";

$ Exist = preg_match ("/B {$ B} B/", $ );

If ($ exist)

{

Echo "exists ";

} Else

{
Echo "does not exist ";
}


Take a look at the relevant instructions

Int preg_match (string pattern, string subject [, array matches [, int flags]);
Preg_match () returns the number of times pattern matches. Either 0 (no match) or 1 time, because preg_match () will stop searching after the first match. Preg_match_all () indicates that, on the contrary, the end of the subject is always searched. If an error occurs in preg_match (), false is returned.
Example:

The code is as follows: Copy code

<? Php

$ A = "abcdefgabcdefaaag ";

Preg_match ('| abc ([a-z] +) g | isu', $ a, $ out1 );

Preg_match_all ('| abc ([s] +) g | isu', $ a, $ out2 );

Echo "<pre> ";

Print_r ($ out1 );

 

Print_r ($ out2 );

Echo "</pre> ";

?>

Statement:
When double quotation marks are used, they are different from single quotation marks.

The code is as follows: Copy code

<? Php

Preg_match_all ("/href =" (. *) "/isu", $ contents, $ out );

Preg_match_all ('| href = "(. *)" | isu', $ contents, $ out );

?>

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.