Reputation: 586
hello every one i need a validation that can only validate to character and white space.. no mater how much space and character in text-box
i use this regexp validation below. but its only allow one space between two words but don`t allow the third space for third word.
([A-Za-z])+( [A-Za-z]+)
how to allow only characters and spaces in Regexp Validation?
Upvotes: 4
Views: 13477
Reputation: 39355
Try this:
([A-Za-z])+( [A-Za-z]+)*
^^ here
*
means to repeat the group zero or more times. If you need it to be one or more times, then use +
. Another thing you can use [ ]+
instead of space to handle one or more consecutive spaces.
Also, if you need, you can use anchor ^
and $
around your regex. Like ^...regex...$
Upvotes: 4
Reputation: 32189
You can do it as:
^([\sA-Za-z]+)$
Demo: http://regex101.com/r/mQ0jN4
Upvotes: 1