Richard Tookey wrote:If indeed the OP just wants to handle spaces and not white spaces then the responses so far are probably the best approach but if white spaces are to be white spaces in the regex sense then...
Actually, if you look at the docs for
String.trim(), you'll see that it removes all characters at
or below '\u0020' (the space character) from the start and end of a String, which is pretty darn close to regex's interpretation of whitespace (although, as you say, not exactly the same).
BTW, Thanks Paul. I hadn't even noticed that 1.6 added the
isEmpty() method. Amazing what you miss sometimes.
Winston