Help needed in Regex Patterns

<h3 style=" text-align: left; margin-top: 10px;">abcd</h3>

I need to extract abcd ? How to extract it?

I m using this code :

preg_match_all("/<h3 style=\\" text-align: left;\\" >(.*?)<\\/h3>/i",$html, $n);

But its not working… Any help will be appreciated. :slight_smile:

Hi,

Parsing HTML with a regular expression is almost never a good idea.

That said, try this:

$matches = null;
$returnValue = preg_match('/<h3 .*>(.*)<\\\\/h3>/', '<h3 style=" text-align: left; margin-top: 10px;">abcd</h3>', $matches);
print_r($matches);