Sometimes we need to filter or extract external links from HTML strings. Below I will introduce a program that uses PHP regular expressions to extract href addresses in HTML hyperlinks for your reference.
Use PHP's regular expression related functions to extract the address in the html hyperlink .
The code is as follows
|
Copy code
|
||||
$preg='//is'; $str ='URLNAMEText 1URLNAMEText 2< a target="_blank" href="Link 3">URLNAME...Text segmentn';
|
Attached is a PHP regular expression code to extract image address.
The code is as follows | Copy code |
$str='
|