preg_match_all
| From: | Chris W | Date: | Thu, 29 May 2008 18:07:11 +0000 |
| Subject: | preg_match_all | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-274827@lists.php.net to get a copy of this message | ||
What I want to do is find all links in an html file. I have the pattern below. It works as long as there is only one link on a line and as long as the whole link is one line. It seems there should be a way to get this to work with more than one link on a single line. The work around I have done for now is to read the whole file into a buffer and remove all new lines and then add a new line after every closing a tag. Then process each line. There has to be a better way.
Any Ideas? Also note I don't want to find any a tags that don't have an href.... there probably aren't any but just in case.
preg_match_all("/(< *a[^>]*href[^>]+>)(.*)<\/a>/", $Line, $matches, PREG_PATTERN_ORDER);
--
Chris W
KE5GIX
"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm"
Ham Radio Repeater Database.preg_match_all("/(<
*a[^>]*href[^>]+>)(.*)<\/a>/", $Line, $matches, PREG_PATTERN_ORDER);
http://hrrdb.com