Java doesn't see space in string [closed]

Solution 1:

I suspect that you have in your text character which is similar to non-breakable-space which is not white space so it can't be matched via \\s.

In that case try to use \p{Zs} instead of \s.

As mentioned in http://www.regular-expressions.info/unicode.html

\p{Zs} will match any kind of space character

BTW if you would also like to include other separators than spaces like tabulators \t or line breaks \r \n you can combine \p{Zs} with \s like [\p{Zs}\s]