To work, you need to quote backslashes inside strings.
For example, the following works just fine:
public class testprog {
public static void main(String args[]) {
String s = "Hello there";
System.out.println (s.matches(".*\\s.*"));
}
}
Conclusion:
true
If you use a type string "\s", you should receive an error message:
Invalid escape sequence - valid ones are \b \t \n \f \r \" \' \\
, \s escape- ( , ).