I am writing a form validation class and wish to include regular expressions in the validation. Therefore, the regex provided isn\'t guaranteed to be valid.
How can
Anyone still looking at this question anno 2018, and is using php 7, should be using try/catch.
try { preg_match($mypattern, ''); } catch (\Throwable $exception) { // regex was invalid and more info is in $exception->getMessage() }