I have a website which contains a search box which allows a user to enter a pattern which is then checked against large strings to see are there any matches within these strings for the user specified pattern. This is done using the PHP function preg_match()
.
However the problem occurs when the user enters an invalid pattern e.g one which causes an error like:
preg_match() [function.preg-match]: Unknown modifier.
The search feature needs to be able to handle any errors thrown by the preg_match()
method and display a general pattern invalid message on the screen. I've looked online but I can't find a one catch all way of catching any error preg_match()
can throw, anyone got any ideas?