$re = '/((?:[^;\']*?(?>\'(?:|.*?(?:[^\\\\]|[^\\\\]?(?:\\\\{2})+))\'))*.*?);/s';
$str = 'INSERT INTO `table_c` VALUES (\'aaa\',5,1,\'0000-00-00\'),(\'bbb\',6,2,\'2015-12-17\'),(\'bbb1\',7,3,\'2015-12-17\'),(\'bbb2\',8,4,\'2015-12-16\'),(\'bbb3\',9,10000000,NULL),(\'bbb4\',10,10000000,NULL),(\'bb\\\';;;b5\',10,10000001,NULL),(\'bbb6\',10,10000002,NULL),(\'bbb7\',10,10000003,NULL),(\'bbb8\',9,10000004,NULL),(\'a\\";\\"b\',9,10000005,NULL),(\'a\\\';\\"\\\'b\',9,10000006,NULL);
abc;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
ddd\';\\\'\\\\\\\'\' ;';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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