So far I have
^[a-z0-9]+[a-z0-9\x20]+[a-z0-9]+$
Which matches all criteria except not matching double spaces.
So far I have
^[a-z0-9]+[a-z0-9\x20]+[a-z0-9]+$
Which matches all criteria except not matching double spaces.
Try this:
^[a-z0-9](?: ?[a-z0-9])*$
As seen on rubular
a_bc # match (underscore '_' represents space)
abc # match
a_ # no match
_a # no match
a__b # no match
(You can replace the whitespace after the ?:
with \x20
if you have to)
Something along these lines should work:
^[a-z0-9]+((\x20)?[a-z0-9]+)*$
This will mean you can have letter or number at the start, one or more times, followed by a block containing a space 0 or 1 times, followed by 1 or more letters or numbers, which can be included 0 or more times.
Edit: I think this should work. Can only have 0 or 1 spaces in between blocks of letters/numbers.
How about:
^[a-z0-9]+(\x20[a-z0-9]+)*$
One or more letter or numbers, followed by a space & one or more letters/numbers, repeated 0 or more times.