Trying to assign as String variable the regular expression but Eclipse IDE doen’t allowing to do that. Why?

Trying to assign as String variable the regular expression but Eclipse IDE doen’t allowing
Share
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.
You have to use “
\\s” instead. This is because\sisn’t aStringescape, rather it is used in the regex. Java will see your string and change the\\into a single\(as\\is a\escaped). You will also have to do this for all of the other escapes (likepattern = "(\\s)*(\\w\\w(\\w)*)...)To make this more understandable, you know how you can put quotes in a
String(likeString s = "He said, \"Wow.\"";)? Well, you can put backslashes in aStringby escaping them like\\. Then it will send those backslashes to the regex functions/classes, which will then understand them.