 <pre><code>preg_match(";from"&gt;&lt;span class="profile fn&gt;(.?)&lt;/span&gt;&lt;/div&gt;;", $text, $match) </code></pre> <p>... should trigger this:</p> <blockquote> <p>Parse error: syntax error, unexpected '&lt;'</p> </blockquote> <p>Apart from that:</p> <ul> <li><p>You seek for an unclosed attribute that's not in the original text:</p> <p><code>class="profile fn</code> vs <code>class="profile fn"</code></p></li> <li><p>You seek for zero or one characters:</p> <p><code>.?</code></p></li> </ul> <p>Fixed regexp would be:</p> <pre><code>$text = '&lt;div class="from"&gt;&lt;span class="profile fn"&gt;firstnamed familyname&lt;/span&gt;&lt;/div&gt;'; preg_match(';from"&gt;&lt;span class="profile fn"&gt;(.*)&lt;/span&gt;&lt;/div&gt;;', $text, $match); var_dump($match); </code></pre> <p>Of course, this will probably break on large HTML documents (as soon as there's another <code>&lt;/span&gt;&lt;/div&gt;</code> bit later on). Regular expressions are impossible to get right when used for parsing HTML.</p>