1. The role of regular expressions: split, search, match, replace strings
2. Separator: forward slash ( /), hash symbol (#) and negation symbol (~).
3. Universal atoms: \d \D \s \S \w \W
4. Atomic symbols
6. Back reference
7. Greedy mode
8. Regular expression PCRE functionprge_match()
, preg_match_all()
, preg_replace()
, preg()_split()
.
Solution Question method method
Write a string to be matched
Use atoms and metacharacters of regular expressions to splice from left to right
Finally Add correction mode
Practice common regular expressions (mobile phone number, ID card, email, url, etc.)
Mobile phones starting with 139 Number
$str = '13988888888'; $partten = '/^139/d{8}$/'; preg_match($partten, str, $match); var_dump($match);
Get the sr value of all img tags in the html page
$str = '<img id=content"" src="高清无码.jpg" alt="高清无码">'; $partten = '/<img .*?src="(.*?)".*?\/? alt="Regular expressions of PHP basic knowledge inspection points" >/i'; preg_match($partten, $str, $match); var_dump($march);
The above is the detailed content of Regular expressions of PHP basic knowledge inspection points. For more information, please follow other related articles on the PHP Chinese website!