Parentheses are meta-characters in regular expressions. Hence you are actually trying to match John Smith
(without parentheses). What you need to do is to escape them.
Java has a built-in function to escape all meta-characters automatically: Pattern.quote
. Run s
through this function and it should fix it.
Also note that you might want to surround the pattern with ^...$
. Otherwise it would accept rows containing something like This is John (Smith) foobar.
(because the regex is glad if it can match a substring of the input).