I need to check a String is "\++?" which will match something like +6014456
But I get this error message invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\) …. why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s giving you an error because
"\++?"isn’t a valid Java literal – you need to escape the backslash. Try this:However, I don’t think that’s actually the regular expression you want. Don’t you actually mean something like:
That corresponds to a regular expression of
\+\d+, i.e. a plus followed by at least one digit.