Test if a regular expression is a valid one in PHP
$subject = "PHP is the web scripting language of choice.";
$pattern = 'sssss';
You can just wrap
preg_match with try catch, and consider result false, if it throws exception.
Anyway, you can take a look at regular expression to detect a valid regular expression.