<?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