I would like to do a regular expression that does not allow more than 1 consecutive spaces.
For example:
A Bb 7is validAA Ois not valid00 55is validA bis not valid
I would like to do a regular expression that does not allow more than 1 consecutive spaces.
For example:
A Bb 7 is validAA O is not valid00 55 is validA b is not validDepending on your exact needs I can provide two versions:
This works with only the "space" character, but does not take other spacing characters from Unicode into account:
^[^ ]*(?: [^ ]+)* ?$
That takes the regex spacing characters into account, so also uses newlines, tabs etc. as "space":
^\S*(?:\s\S+)*\s?$
Both regular expressions match when they find a valid input.