I have a password box that I am going to check against a Regex pattern. I have already got two other identical type of functions that work correctly on non password text boxes.
This is my function:
public bool CheckPassword(string password)
{
string patternStrict = @"/^(?=.*[a-zA-Z])(?=.*\d)\S{6,15}$/";
Regex reStrict = new Regex(patternStrict);
bool isStrictMatch = reStrict.IsMatch(password);
return isStrictMatch;
}
and I am inputting a test to it like so:
Problem.Text = CheckPassword(passwordbox.Text);
The TextBox I am using (passwordbox) is filtered with * as the password character and that works but I am wondering if that is the cause for the function to fail?
I feel it is something obvious I have missed. The response should come back as true but it is coming back as false. See line 5 of the link supplied above as the test line to see if it works, that is the test line I am using to check if it works.
.NET does not need a regex delimiter, so just remove the leading and the trailing slash: