A blank line, which may include, line breaks,  , and spaces. When processing a string, it is unavoidable to encounter a blank line processing.
1, replace blank lines, blank lines can include spaces, ,\t,\f,\n
$s = preg_replace ('/(^ (\s| ) *$)/M ', ', $s);
2, replace blank lines, including line breaks only
$s = preg_replace ('/($\n\r*$) | ( ^\n\r*^)) +/m ', ', $s)
3, replace the blank line, and remove the whitespace from the beginning and end of the Non-empty line
$s = preg_replace ('/^ ( |\s) *| ( |\s) *$/m ', ', $s);
4, does not match the blank line, directly does not match the blank line, is very difficult. Actually does not match the blank line, is matches the Non-empty line
Preg_match_all ('/\s+/m ', $s, $match);
5, multiple-line matching instance
$s =
test:
11111
22222
33333333333333333333 br> 44444444444444444444
";
$s = preg_replace ('/(^ (\s| ) *$)/M ', ' <br > ', $s);
$pa = "/test: ((\s) *[^<]*) *)/I";
Preg_match ($pa, $s, $m);
Echo $m [1];
matches the null and void between rows from the test line to the bottom, and is also 11111,22222
6, characters in the common matching pattern
I mode will match both the uppercase and lowercase letters
m strings as multiple lines
S treats the string as a single line, and the newline character as a normal character
X ignores the white space in the pattern by ignoring the
e preg_replace () function to replace the reverse reference in the replacement string, using it as a PHP code evaluation and replacing the searched string with its result.
A forces only the beginning of the target string to match
the $ metacharacters in D mode match only the end of the target string
U matches the nearest string
U pattern string is treated as UTF-8