Skip to content

regular expression PHP example for non-programmers

When asked to help a friend make an easy way to parse a web page, I suggested using regular expressions. PHP is currently my language of choice, so in a few minutes I hacked together a well-documented (in my opinion) php script that will pull apart a table in an otherwise very messy web page.  I made a trivial attempt to obscure the source of this data, which is public domain, but included are the originally downloaded web page, the extraction script, and the output in either CSV form or another plain HTML page.

The assumption for using this script is that you can download the target page yourself (either through a crawler like curl or wget) or by the "Save as" link in your browser.  If not, solve that problem first and then come back for the script.

Helpful links (thanks Eric L.) for learning regular expressions yourself (not a comprehensive list)...

Download: Regular Expression Example

Post a Comment

Your email is never published nor shared. Required fields are marked *