title: Is it possible to catch any error from preg_match and display a common error message?
body: <p>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 <code>preg_match()</code>.</p>
  
  <p>However the problem occurs when the user enters an invalid pattern e.g one which causes an error like: </p>
  
  <blockquote>
    <p>preg_match() [function.preg-match]: Unknown modifier.</p>
  </blockquote>
  
  <p>The search feature needs to be able to handle any errors thrown by the <code>preg_match()</code> 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 <code>preg_match()</code> can throw, anyone got any ideas?</p>