Home>Article>Backend Development> Regular expressions of PHP basic knowledge inspection points

Regular expressions of PHP basic knowledge inspection points

藏色散人
藏色散人 forward
2020-01-27 14:40:28 2863browse

Regular expressions of PHP basic knowledge inspection points

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

Regular expressions of PHP basic knowledge inspection points

4. Atomic symbols

Regular expressions of PHP basic knowledge inspection points

5.Pattern modifier

Regular expressions of PHP basic knowledge inspection points

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 = '高清无码'; $partten = '/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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete