SCENARIO :
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" WhiteSpace");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" WhiteSpace");
I am trying to get whitespaces at the beginning of a line. I want to get exact number of white spaces matcher true. My string is " WhiteSpace".
Problem is both matcher and matcher2 work on this string.
The thing I want is:
A pattern that only get 1 white space, but this pattern should not work
for 2 white space string. In the scenario below both matcher.find() and matcher2.find() are true. But matcher.find() should be false, matcher2.find() should be true.
I want matcher to be true for :" WhiteSpace"" WhiteSpace",
I want matcher 2 to be true false for :" WhiteSpace"," WhiteSpace" (two spaces)
I want matchermatcher2 to be falsetrue for :" WhiteSpace",
SCENARIO :" WhiteSpace".
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" WhiteSpace");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" WhiteSpace");
The thing iI want to do is;
I have a string " two whitespaces"" two whitespaces".
Below both if statements are true. matchermatcher should be false.
matcher2matcher2 should be true.
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" twotwo whitespaces");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" twotwo whitespaces");
if(matcher.find==truefind()==true){
//XXXXXXXXXXX
} else if(matcher2.find==truefind()==true){
//YYYYYYYYYYY
}
Thanks,
I am trying to get whitespaces at the beginning of a line. I want to get exact number of white spaces matcher true. My string is " WhiteSpace".
Problem is both matcher and matcher2 work on this string.
The thing I want is:
A pattern that only get 1 white space, but this pattern should not work
for 2 white space string. In the scenario below both matcher.find() and matcher2.find() are true. But matcher.find() should be false, matcher2.find() should be true.
I want matcher to be true for :" WhiteSpace",
I want matcher 2 to be true for :" WhiteSpace",
I want matcher to be false for :" WhiteSpace",
SCENARIO :
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" WhiteSpace");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" WhiteSpace");
The thing i want to do is;
I have a string " two whitespaces".
Below both if statements are true. matcher should be false.
matcher2 should be true.
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" two whitespaces");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" two whitespaces");
if(matcher.find==true){
XXXXXXXXXXX
} else if(matcher2.find==true){
YYYYYYYYYYY
}
Thanks,
SCENARIO :
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" WhiteSpace");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" WhiteSpace");
I am trying to get whitespaces at the beginning of a line. I want to get exact number of white spaces matcher true. My string is " WhiteSpace".
Problem is both matcher and matcher2 work on this string.
The thing I want is:
A pattern that only get 1 white space, but this pattern should not work
for 2 white space string. In the scenario below both matcher.find() and matcher2.find() are true. But matcher.find() should be false, matcher2.find() should be true.
I want matcher to be true for" WhiteSpace", false for" WhiteSpace" (two spaces)
I want matcher2 to be true for :" WhiteSpace".
The thing I want to do is;
I have a string " two whitespaces".
Below both if statements are true. matcher should be false.
matcher2 should be true.
Pattern whitespace = Pattern.compile("^\\s");
matcher = whitespace.matcher(" two whitespaces");
Pattern whitespace2 = Pattern.compile("^\\s\\s");
matcher2 = whitespace2.matcher(" two whitespaces");
if(matcher.find()==true){
//XXXXXXXXXXX
} else if(matcher2.find()==true){
//YYYYYYYYYYY
}