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.<h2>Output should be:</h2>
[ India Bangalore ]
i.e : user can enter the spaces in between the words but not in first position and last position.
Try this please :
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
Any way calling Trim() method on input string in server-side is much easy .Answer2:
Trim() should remove any trailing or leading spaces.