Extract Unknown Number of URLs from String and Validate Links

Nerd Bombs

On one of my websites, I maintain hyperlinks within a free text field of my MySQL database.  Although there are benefits to maintaining this html in my content management system and not individually in thousands of pages, it does complicate testing all of these links.  So my goal was to create an html table which summarizes all of the rows in my database which contain links and extracts all of the URLs within the “Explanation” field as additional columns.  This way, I can test all of the URLs to ensure that none of them are broken.  Here’s an example of the summary I’m trying to create:

Acronym Definition Explanation (free text field that contains an unknown number of links) # Links Link 1 Link 2 Link n
AA Administrative Assistant
Explanation of AA that contains <a href='http://link 1.com'>this link</a> and <a href='http://link 2.com'>this link</a>
http://link 1.com
http://link 2.com

View original post 237 more words