I may be wrong, but there's no way to expect an exception whose message matches a regular expression pattern. Reading the exception.php source code I found this comment: "This could be improved to accept a pattern expectation to test the error message, but that will have to come later."
Please, find attached 2 patches and a sample UnitTestCase
I didn't use a pattern expectation but an exception object whose message contains a regex pattern. It's not elegant, but it allows the exception type to be tested too.
Patch for exceptions. Added ExceptionPatternExpectation
Added expectExceptionPattern()
A simple UnitCaseTest testing with ExpectExeptionPattern. It requires the sample ThrowException class too
A sample class with a method throwing an exception