By pfaocle on
Hey,
One thing I've always been useless at is regular expressions. Basically I need a regex to parse out three elements of an anchor (a) tag: the url, the title attribute, and the link text inbetween the a tags. So:
<a href="/my/url" title="a description">link text</a>
becomes an array:
array( 'url' => 'my/url', 'title' => 'a description', 'text' => 'link text')
or somesuch. Any help is appreciated, thanks!
Comments
Here is the code, modify it for your needs
All at once
I think you can have all at once? Why not?
Seems like the input filters for forum cant handle my code post, this is the regexp again:
There is a great tool available at http://www.weitz.de/regex-coach/ which can help you
developing new RegExps. For your purpose you should try with 'split' option.
your code has an error
change
to
which is some (title changed with href) but you can't parse that :)
Excellent, thank you very
Excellent, thank you very much. Here's the application:
which sits in a PHPTemplate template file for the primary/secondary links, allowing me to insert the title attribute of the link underneath the link itself in the theme.
Thanks again!
---
paul byrne
paul.leafish.co.uk | www.leafish.co.uk
---
Paul Byrne
pfaocle.co.uk | CTI digital
My suggestion
Don't need uses the modifiers 'm' and 'U'.
My suggestion:
Accept valids values: