Hi,
Try this regular expression:
<br />
^[^ ].+[^ ]$<br />
To validate the password with the regular expression:
C#:
bool passwordIsInCorrectFormat = System.Text.RegularExpressions.Regex.IsMatch(password,"^[^ ].+[^ ]$");
VB.NET:
Dim passwordIsInCorrectFormat As Boolean = System.Text.RegularExpressions.Regex.IsMatch(password, "^[^ ].+[^ ]$")
Hope this helps.