Campbell Ritchie wrote:Do you need the isEmpty() test? Surely \\s+ will pick that up?
Tim Holloway wrote:OK. Let me take a stab. As I read it, the input MUST be exclusively digits EXCEPT that if there is only one digit, then it may be preceeded by one and ONLY 1 space.
So, in raw regex (omitting Java's extra escapes), that should be something like this:
error if it finds whitespace in the beginning of a string if that string is longer than at least 2 characters
Damn! I read it wrongly. Of course you wrote \\d+ and that would fail to match any spaces anywhere.
Carey Brown wrote:, , , What "\\s+" ? . . . .
Robert Ingmarsson wrote:@Tim Holloway!
I tried your regex but it gave me an error exception as listed below
Carey Brown wrote:Tim, you are also missing a paren.