Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
first character and last character should not accept space and in middle it can accept space's can u tell me the regular express ,how can i validate..
Posted

1 solution

Hi,

Try this regular expression:
<br />
^[^ ].+[^ ]$<br />

To validate the password with the regular expression:
C#:
C#
bool passwordIsInCorrectFormat = System.Text.RegularExpressions.Regex.IsMatch(password,"^[^ ].+[^ ]$");

VB.NET:
VB
Dim passwordIsInCorrectFormat As Boolean = System.Text.RegularExpressions.Regex.IsMatch(password, "^[^ ].+[^ ]$")

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900