Review regular expressions in PHP (1) first review common regular expression functions in php.
1. preg_match () and preg_match_all ()
Int prag_match ($ pattern, $ subject, optional parameter $ matchs); only one match is performed, and the return value is 0 or 1, that is, the number of matching times, put the matched value into the third parameter, which is an array.
Int preg_match_all ($ pattern, $ subject, optional parameter $ matchs); to perform all matching, the returned value is also the number of matching times, put the matching value to the third parameter, is a two-digit array.
2. preg_replace () and preg_filter ()
Preg_replace ($ pattern regular, $ replacement content to be replaced with, $ subject target content); all three parameters can be arrays
Preg_filter (same as above); same as above
One difference between the two functions is that, when an array is used for matching, the returned value is preg_filter (), which returns only the replaced value, and the preg_replace () returns no matter whether it is replaced or not.
Preg_grep (); returns the matched value without replacement. This is equivalent to a function reduction version of preg_filter.
3. preg_split ($ pattern, $ subject );
Needless to say, an upgraded version of The explode () function.
4. preg_quote ($ str );
You can wake up and escape the regular expression operators in a string.