I am at the point where I am banging my head against my desk, to the amusement of my colleagues. I currently have the following regex
(^[\w](( \w+)|(\w*))*[\w]$)|(^\w$)
What I want it to do is match any string which contains only alphanumeric characters, no leading or trailing whitespace and no more than one space between words.
A word in this case is defined as one or more alphanumeric characters.
This matches most of what I want, however from testing it also thinks the second word onwards must be of 2 characters or more in length.
Tests:
ABC - Pass
Type 1 - Fail
Type A - Fail
Hello A - Fail
Hello Wo - Pass
H A B - Fail
H AB - Pass
AB H - Fail
Any ideas where I'm going wrong?