Reputation: 3
I have a textbox and have to use the regular expressions in asp.net
My text should not allow the spaces in first and last place.
Valid:
[India Bangalore]
Not valid:
[ India Bangalore ]
i.e : user can enter the spaces in between the words but not in first position and last position.
If you have solution in JavaScript that is also fine.
Upvotes: 0
Views: 619
Reputation: 3235
Try this please :
^[^\s].*[^\s]$
It simply match input which:
not to start with any white space ^[^\s]
followed by any character even white spaces .*
and not end with any white space [^\s]$
.
Any way calling Trim() method on input string in server-side is much easy .
Upvotes: 0