Thought I would share a little trick validating your handcrafted regex to be error free. Well error free in syntax...

PHP Code:
function preg_validate_regex $pattern )
{
    
// We need to have an error handler that returns false. In case of a
    // custom error handler we'll dynamicly create one.
    
set_error_handlercreate_function'''return false;' ) );

    if ( @
preg_match$pattern'' ) === false ) {
        return 
false;

        
# Or can do...
        
$e error_get_last(); $e $e['message'];
        
$e substr$estrpos$e':' ) + );
        throw new 
Exception$e );
    }

    
restore_error_handler();
    return 
true;

The set_error_handler() is important if you want to extract the error message from error_get_last() and it must return false. Honestly, it is not really that important, it is here just as a procaution.

As you can see adove we are using preg_match() with an empty subject. Not looking for any matches it will safetly return zero (0), while an invalid pattern returns false. Can return false here or create an Exception with the reason of failure along with it.

Must of course restore the previous error handler with restore_error_handler(). However, now that I think about it it needs to be run regardless if the outcome is false or true or before the exception

Variation one, returning only a boolean:
PHP Code:
function preg_validate_regex $pattern )
{
    
set_error_handlercreate_function'''return false;' ) );
    
$t = ( @preg_match$pattern'' ) === false ) ? false true;
    
restore_error_handler();
    return 
$t;

Variation two, using Exception:
PHP Code:
function preg_validate_regex $pattern )
{
    
set_error_handlercreate_function'''return false;' ) );
    
    if (  @
preg_match$pattern'' ) === false ) {
        
$e error_get_last(); $e $e['message'];
        
$e substr$estrpos$e':' ) + );
    }

    
restore_error_handler();
    if ( isset( 
$e ) ) throw new Exception$e );
    return 
true;

The two above should correctly handle restoring the error handler.

I've Been working on this for my framework, which I decided to make an overly complicate regular expression's interface. You can see how I use this method here. And the other parts here. Be warned I am using PHP 5.3 and its full feature set.