Hi I have tried the following and it seems not working. Can you explain me why ?
public class Solution {
public static void main(String[] args) {
String abc =" ";
String regx = ".*[^\\s].*";
if (abc.matches(regx)) {
System.out.println("true");
} else {
System.out.println("false");
}
}
}
I have tried another case
public class Solution {
public static void main(String[] args) {
String abc =" ";
String regx = ".*[^\\s].*";
Pattern r = Pattern.compile(regx);
Matcher m = r.matcher(abc);
if (m.find()) {
System.out.println(true);
} else {
System.out.println(false);
}
}
I have given abc = " ",abc = " ". in all the case i am getting false as output.I dont understand why ?
Thanks.