Take it into account before use this function.
My php --version
PHP 5.6.29 (cli) (built: Dec 8 2016 09:19:46)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
On Linux Fedora 23 4.8.13-100.fc23.x86_64 #1 SMP Fri Dec 9 14:51:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
<?php
// @see http://stackoverflow.com/questions/4440626/how-can-i-validate-regex
// returns true because there is no opening "(" for the closing ")"
var_dump(preg_match('~InvalidRegular)Expression~', null) === false);
// this SHOULD be something different from 0, but...
var_dump(preg_last_error());
?>