$re = '/.+>([^>]+)$/';
$str = '<div><pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span><span style="color:rgb(51,51,51);font-weight:bold">function</span> <span style="color:rgb(153,0,0);font-weight:bold">syntaxHighlighting</span><span>()</span> </span>{
<span style="color:rgb(51,51,51);font-weight:bold">var</span> n = <span style="color:rgb(0,128,128)">33</span>;
<span style="color:rgb(51,51,51);font-weight:bold">var</span> s = <span style="color:rgb(221,17,68)">"hello, こんにちは"</span>;
<span style="color:rgb(0,134,179)">console</span>.log(s);
}
</code></pre>
';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php