View Single Post
Old 12-05-2003, 02:36 AM  
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
I'll be nice and share one regexp

This grabs all linked images on a page:

PHP Code:
/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im 
In PHP, do it like this:

PHP Code:
preg_match_all("/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im"$string$matches
$matches is an array with all of the images with links. Just change up the regexp for plain links, images, etc.
__________________
&nbsp;
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote