note 64098 rejected from function.preg-match by bjori

From: Date: Fri, 07 Apr 2006 14:55:15 +0000
Subject: note 64098 rejected from function.preg-match by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107518@lists.php.net to get a copy of this message
Note Submitter: whilelord at gmail dot com ---- How can i retrieve all href links on HTML page (such as Google) with their name attributes? I mean, i want to gather both href="..." and name="..." in <a href="http://www.google.com/" name="GoogleLink"> Of course, there are some variations of a tag such as; <a href="http://www.google.com/" name="GoogleLink"> <a name="GoogleLink" href="http://www.google.com/"> <a id="test" href="http://www.google.com/" name="GoogleLink"> <a href="http://www.google.com/" id="test" name="GoogleLink"> <a href="http://www.google.com/" name="GoogleLink" id="test"> I want a pattern which will find all these links and gather both href and name values. I can easily gather href values easily with the following pattern: $TMPPattern = "/(href|HREF)=[\"|\'](.*)[\n|\r|\"|\']/iU"; preg_match_all($TMPPattern, $String, $ArrayMatches, PREG_SET_ORDER); But i need more advanced one for gathering corresponding "name" values also :( Please help! Thanks!

« previous php.notes (#107518) next »