note 64098 added to function.preg-match
| From: | whilelord at gmail dot com | Date: | Fri, 07 Apr 2006 11:21:50 +0000 |
| Subject: | note 64098 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107508@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 66.163.161.117
Probable Submitter: 85.105.232.73
----
X-Spam-Status: No, hits=4.2 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_40_50,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/note/edit/64098
Del: integrated -- http://master.php.net/note/delete/64098/integrated
Del: useless -- http://master.php.net/note/delete/64098/useless
Del: bad code -- http://master.php.net/note/delete/64098/bad+code
Del: spam -- http://master.php.net/note/delete/64098/spam
Del: non-english -- http://master.php.net/note/delete/64098/non-english
Del: in docs -- http://master.php.net/note/delete/64098/in+docs
Del: other reasons-- http://master.php.net/note/delete/64098
Reject -- http://master.php.net/note/reject/64098
Search -- http://master.php.net/manage/user-notes.php