(
' )? $str =" SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'zagolovok-dlya-rubriki-13022020' for key 'blog_categories_slug_unique' (SQL:bla-bla-bla........";
preg_match('/(^\sSQLSTATE.*)(\(SQL:)/', $str , $matches);
var_dump($matches[1]);