如何调试发送到PHP函数的正则表达式字符串?

I use this function to replace thousands of regex codes:

function preg_replace_assoc(array $replace, $subject) {
   return preg_replace(array_keys($replace), array_values($replace), $subject);
}

Now I upgraded to PHP 5.3.10 and I get some errors like:

Warning: preg_replace(): Compilation failed: missing ) at offset 18

Warning: preg_replace(): Compilation failed: nothing to repeat at offset 35

Warning: preg_replace(): Unknown modifier '-'

How can I debug this? PHP doesn't print the array keys.

Write a simple loop for the array, and do key-value replaces one by one - before replace, print the key-value pair.

This way you will know which is the offending expression.