A good thing to keep in mind is that regex strings are always "compiled" into Pattern objects
at runtime. When you get a compile-time error about escape sequences, it isn't talking about your
regex syntax, it's talking about your
String literal syntax. As Jeanne said, it's telling you that you failed to escape your backslashes.
In this case, however, you could just as easily fix the error by
removing the backslashes. Of the four escaped characters in that regex, only the hyphen has a special meaning inside a character class, but not if it's the first or last character listed. The period loses its usual special meaning, and the apostrophe and the comma never had them. And we should never pass up a chance to reduce the number of backslashes in our regexes. ^_^
It's not really a big deal in a situation like this, where the regex is applied in response to user input and the target strings are relatively short, but that regex is much more complicated and inefficient than it needs to be. The intention is obviously to make sure every punctuation character is followed by at least one letter; here's a clearer, quicker way to express that:
I have a much bigger problem with the notion of applying arbitrary, simplistic validation rules to name-entry fields. No computer has yet told me that I'm misspelling my own name, but if one ever does, the owner of that computer will not be doing any business with me if I have any choice in the matter. ^_^