Let's review the common regular expression functions commonly used in PHP.
1. Preg_match () and Preg_match_all ()
int Prag_match ($pattern, $subject, optional parameter $matchs); Only one match is made, the return value 0 or 1, that is, the number of matches, the value to be matched into the third argument, is an array.
int Preg_match_all ($pattern, $subject, optional parameter $matchs); For all matches, the return value is also the number of matches, and the matching value is placed in the third parameter, which is a two-bit array.
2. Preg_replace () and Preg_filter ()
Preg_replace ($pattern Regular, $replacement the content to be replaced, $subject the target content); All three parameters can be arrays
Preg_filter (ibid.); ibid.
One difference between these two functions is that when the array is matched, the return value, Preg_filter () returns only the value that is replaced, and preg_replace () returns regardless of whether it is replaced or not.
Preg_grep (); match only, do not replace, return the match to the value. equals a reduced version of a preg_filter () feature.
3. Preg_split ($pattern, $subject);
Needless to say, an upgraded version of the explode () function.
4. Preg_quote ($STR);
You can escape the regular expression operator in a string by awakening it.