In the RegExp class the error messages in exceptions is either the pattern or an empty string but uses preg_last_error() as exception code to classify the error. This is not optimal to quickly debug an invalid regex.
Instead preg_last_error_msg() should be used as exception messages to better pinpoint what's wrong. The use of the exception code must be kept as is to still allow to classify the errors (to prevent a BC break).
In the
RegExpclass the error messages in exceptions is either the pattern or an empty string but usespreg_last_error()as exception code to classify the error. This is not optimal to quickly debug an invalid regex.Instead
preg_last_error_msg()should be used as exception messages to better pinpoint what's wrong. The use of the exception code must be kept as is to still allow to classify the errors (to prevent a BC break).