src/Parser/Checker.php
public function isValidRegex()
    {
        set_error_handler(function ($errno, $errstr) {
            throw new InvalidArgumentException($errstr, $errno);
        }, E_WARNING);

        $valid = true;

        try {
            preg_match($this->string, 'tester');
        } catch (InvalidArgumentException $e) {
            $valid = false;
        }

        restore_error_handler();

        return $valid;
    }
public function isValidRegex()
    {
        set_error_handler(function ($errno, $errstr) {
            throw new InvalidArgumentException($errstr, $errno);
        }, E_WARNING);

        $valid = true;

        try {
            preg_match($this->string, 'tester');
        } catch (InvalidArgumentException $e) {
            $valid = false;
        }

        restore_error_handler();

        return $valid;
    }
public function isValidRegex ( ) { set_error_handler ( function ( $ errno , $ errstr ) { throw new InvalidArgumentException ( $ errstr , $ errno ) ; } , E_WARNING ) ; $ valid = true ; try { preg_match ( $ this -> string , 'tester' ) ; } catch ( InvalidArgumentException $ e ) { $ valid = false ; } restore_error_handler ( ) ; return $ valid ; }
Confirms if a string is a valid regular expression.

@return bool true if the string is a valid regex, false otherwise
Confirms if a string is a valid regular expression .