tags:

views:

82

answers:

2

Possible Duplicates:
How to get string from HTML with regex?
RegEx match open tags except XHTML self-contained tags

Hey there.
So i have some HTML code that i need to parse. I was wondering what the regex would look like to do this?

Basically the HTML is a large HTML document. The structure looks something like this.

//Random HTML
//Random HTML
//Random HTML
<h4>Description</h4>
<p>This is the text i need</p>
//Random HTML
//Random HTML
//Random HTML

This is for a PHP script. Hope this make sense?

A: 

Many similar questions on stackoverflow already. Its always a bad idea to use regex for html parsing. Use html parsers.

Gopi
A: 

So i have some HTML code that i need to parse

So use a parser!

You probably have one built right-in to PHP, in the form of DOMDocument::loadHTML.

Simple HTML DOM also comes highly recommended by others.

Charles
Suggested third party alternatives to SimpleHTMLDom that actually use DOM instead of String Parsing: [phpQuery](http://code.google.com/p/phpquery/), [Zend_Dom](http://framework.zend.com/manual/en/zend.dom.html) and [FluentDom](http://www.fluentdom.org).
Gordon