Just href and rel from anchor tags.
Posted: Mon Feb 25, 2008 3:58 pm
I had to come up with this one the other day to search through all anchor tags for the "href" and "rel" values, in any position in the anchor tag, and ignore all other attributes:
So far it works and does what I need but, man, is that ugly or what?
Just thought I'd share...
Cheers,
Ben
Code: Select all
#<a\s+(?:(?:title|class|id|style)=["\']?[^\'"]*["\']?\s*)*(?:href=["\']([^"\']*)["\']\s*)(?:(?:title|class|id|style)=["\']?[^\'"]*["\']?\s*)*(rel=["\']?(\w+)["\']?)*(?:[^>]*)?>(.*?)</a>#is
Just thought I'd share...
Cheers,
Ben