Php regular expression extracts the title of the image address hyperlink. This article introduces how to use php regular expressions to extract the title of an image URL hyperlink. For more information, see. The following is a copy of the id code in the regular expression extraction URL. This article describes how to extract the title of an image address hyperlink using the php regular expression. 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 | ';
Refer to the hyperlink title implementation code. For more information, see. The id code in the regular expression extraction URL is copied as follows...