Regular expression U greedy mode

Source: Internet
Author: User

<?php
/*
Pattern correction Symbols:
I u
Location: "//mode modifier position"
You can use one at a time, or you can use multiple
For the whole regular expression tuning, it can also be said to be an extension of the regular expression function
"/abc/": can only match lowercase letter abc
"/abc/i": can be case-insensitive match
M: The string is treated by default as a line ^ $ after multiple lines
Any row can start or end with a regular expression
S: If this mode is not used to correct the symbol. Default cannot represent line break symbols
Treats a string as a single line. You can represent the line break symbol.
x: Whitespace in the pattern is ignored
U: one use correction symbol
The other is to use. *?
*/
Common Regular Expressions:
//
/* $Pdata = "/^a.bchello\s?world/is";
$Pdata = "/(?: a) bc/i";
$string = "A\nbchello World"; */
/* $Pdata = "/\<b\> (. *) \<\/b>/u"; */
$Pdata = "/\<b\> (. *?) \<\/b>/";
$string = "<b>hello</b><b>nihao</b>fadfasdf<b>word</b>fasdfasdf<b>php </b> ";
if (Preg_match_all ($Pdata, $string, $arr)) {
echo "Match succeeded". " <br> ";
echo "<pre>";
Var_dump ($arr);
echo "</pre>";
}else{
echo "Match unsuccessful". " <br> ";
echo "<pre>";
Var_dump ($arr);
echo "</pre>";
}

?>

Regular expression U greedy mode

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.