preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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&amp;PT=PERSONALITIES"; target="_blank">Fake Link 1</a> <a href="http://www.site.com/viewentry.asp?ID=328474&amp;PT=PERSONALITIES"; target="_blank">Fake Link 2</a> <a href="http://www.site.com/viewentry.asp?ID=340492&amp;PT=PERSONALITIES"; target="_blank">Fake Link 3</a> <a href="http://www.site.com/viewentry.asp?ID=339795&amp;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 &amp;, 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux