![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New to the CF scene Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
regular expression to extract html links from a string
hello--I have spent hours now trying to figure this out. it should be simple but I have found it to not be.
I have a string and need to extract the links. So Code:
hello today is a fine day to post a <a href="http://www.linkme.com">link</a> to my favorite website. Code:
<a href="http://www.linkme.com">link</a> So far I have found about a dozen instances of this on the web but they must not have been written for php bc I keep getting errors like "Unknown modifier '['" and others. my own attempt at the regular expression I would need is PHP Code:
I would sincerely appreciate help bc I have just been working on this damn problem for so long. Last edited by ralph.m; 09-24-2006 at 05:58 PM.. Reason: wanted to make it clear I wasn't crawling (I changed "page" to "string" in the title) |
|
|
|
|
|
PM User | #2 |
|
New to the CF scene Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
i found this on one of the other threads...
PHP Code:
|
|
|
|
|
|
PM User | #3 |
|
Master Coder ![]() Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 6,398
Thanks: 40
Thanked 480 Times in 469 Posts
![]() ![]() ![]() ![]() ![]() |
That one you found will work for some anchor tags but not all. It doesn't find tags that use single quotes, for example. But it's a pretty good start.
This will include single quotes too: PHP Code:
|
|
|
|
|
|
PM User | #4 |
|
Regular Coder ![]() Join Date: Aug 2005
Posts: 247
Thanks: 6
Thanked 0 Times in 0 Posts
![]() |
and for extract links only in the form /somedir/ or /somedir ??? Links like /someurl.php or http://www.lalala.com/index.php will be ignored
Regards |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|