This article introduces how to use php regular expressions to extract the title of an image URL hyperlink. For more information, see. The regular expression extracts the id code from the URL as follows to copy the code pre...
This article introduces how to use php regular expressions to extract the title of an image URL hyperlink. For more information, see.
The regular expression extracts the id from the URL
The code is as follows: |
|
Preg_match ('/http://t.sina.com.cn/(d +)/fans //', $ html, $ result); regular expression extracts the id in the URL Echo $ result [1]; |
PHP regular expression to extract the image address code.
The code is as follows: |
|
$ Str =''; $ Pattern = "/<[img | IMG]. *? Src = ['| "] (. *? (? : 2.16.gif |. jpg]) ['| "]. *? [/]?> /"; Preg_match_all ($ pattern, $ str, $ match); print_r ($ match ); |
PHP regular expression to extract hyperlinks and their titles
Using regular expressions is the simplest. other methods, even if you want to use regular expressions, are used...
$ Pat = '/(.*?) /I ';
Preg_match_all ($ pat, $ str, $ m );
Output method:
Print_r ($ m [2]);
Print_r ($ m [4]);
The code is as follows: |
|
$ Str = 'Song list Chinese score list
|
• Light Music | ';
Address:
Reprinted at will, but please attach the article address :-)