Sometimes you need to do preg_replace on user input. Don't forget to escape all special characters or you'll get funny results. Here is how:
$input = str_replace(array('^', '.', '|', '(', ')', '[', ']', '*', '+', '?', '{', '}', '$' ),
array('\^', '\.', '\|', '\(', '\)', '\[', '\]', '\*', '\+', '\?', '\{', '\}', '\$' ), $input);