I\'m looking for a regular expression in Java which matches all whitespace characters in a String. \"\\s\" matches only some, it does not match
and s
You clarified the question the way as I expected: you're actually not looking for the String literal
as many here seem to think and for which the solution is too obvious.
Well, unfortunately, there's no way to match them using regex. Best is to include the particular codepoints in the pattern, for example: "[\\s\\xA0]"
.
Edit as turned out in one of the comments, you could use the undocumented "\\p{Z}"
for this. Alan, can you please leave comment how you found that out? This one is quite useful.