Reputation: 2059
I have this Reg exp
[a-zA-Z]+(([\'\,\.\-\s][a-zA-Z])?[a-zA-Z]*)*$
It allows one space between the words, how can I make this reg exp to accept multiple spaces between the words and spaces after the last word and before the first word.If the user's enters the text with multiple blank spaces how can I trim it to one blank space.
Upvotes: 0
Views: 168
Reputation: 225164
Replace all \s+
with a single space before matching. That handles the trimming and matching at the same time, for no extra cost.
Upvotes: 1