<?php $text = "<p>This is some text here \"</p>\".</p>"; ereg("<p>(([^<\"]|[^<]*<[^\/][^<])*(\"[^\"]*\"([^<\"]|[^<]*<[^\/][^<])*)*)?<\/p>", $text, $matches); echo "Found text: " . $matches[1] . "\n"; ?>