preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
| From: | Micky Hulse | Date: | Wed, 24 May 2006 22:00:08 +0000 |
| Subject: | preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-236857@lists.php.net to get a copy of this message | ||
Hi all,
I have been rtfm on preg_replace, and I am a bit turned-off by how complex reg-exing appears to be.... anyway, I would like to spend some time learning how I would convert a file full of links that look like:
<A HREF=/viewentry.asp?ID=343323&PT=PERSONALITIES TARGET=_top>Fake Link 1</A>
<A HREF=/viewentry.asp?ID=328474&PT=PERSONALITIES>Fake Link 2</A>
<A HREF=/viewentry.asp?ID=340492&PT=PERSONALITIES>Fake Link 3</A>
<A HREF=/viewentry.asp?ID=339795&PT=PERSONALITIES>Fake Link 4</A>
And make them look like this:
<a href="http://www.site.com/viewentry.asp?ID=343323&PT=PERSONALITIES" target="_blank">Fake Link 1</a>
<a href="http://www.site.com/viewentry.asp?ID=328474&PT=PERSONALITIES" target="_blank">Fake Link 2</a>
<a href="http://www.site.com/viewentry.asp?ID=340492&PT=PERSONALITIES" target="_blank">Fake Link 3</a>
<a href="http://www.site.com/viewentry.asp?ID=339795&PT=PERSONALITIES" target="_blank">Fake Link 4</a>
Basically, I would like to make the links/code xhtml transitional, make the links absolute, add quotes where needed, convert & to &, and make them open in a blank window... it would be cool to trash everything except for the url and link description (in other words, if any of the links have, for example, TARGET=_top, it would just ignore and grab only what I want from source file....
Any good links to tutorials and/or resources that teach one how to scrub urls with PHP and regex?
Many TIA!
Cheers,
Micky