This article introduced the use of PHP regular expression to extract the image address hyperlink title Implementation code, there is a need for friends to refer to.
The regular expression extracts the id in the URL
The code is as follows |
Copy Code |
Preg_match ('/http://t.sina.com.cn/(d+)/fans//', $html, $result); The regular expression extracts the id in the URL echo $result [1]; |
PHP's regular expression extracts the code for the image address.
The code is as follows |
Copy Code |
$str = ' '; $pattern = "/<[img| Img].*?src=[' | "] (.*? (?: [. gif|. JPG])) [' | ']. *? [/]?>/]; Preg_match_all ($pattern, $str, $match); Print_r ($match); |
PHP Regular Expressions extract hyperlinks and their headings
Using regular expressions is the simplest, and the other way, even rice to think ...
$pat = '/(. *?) /I ';
Preg_match_all ($pat, $str, $m);
Output method:
Print_r ($m [2]);
Print_r ($m [4]);
The code is as follows |
Copy Code |
$str = ' song list Chinese Melody List
|
• Light Music | ';
http://www.bkjia.com/PHPjc/631607.html www.bkjia.com true http://www.bkjia.com/PHPjc/631607.html techarticle This article introduced the use of PHP regular expression to extract the image address hyperlink title Implementation code, there is a need for friends to refer to. The ID code in the regular expression fetch URL is as follows ...