@lukaszkonieczny did a quick test and regex was slower. But he's going to try with <code>preg_match()</code> instead of <code>preg_replace()</code>.