I've copied a RegEx that's working in Javascript. But when I run it in C# it returns false. I'm not sure if it's my code iteslf that's incorrect or if it is the RegEx. This is my code.
bool isValid = true;
string nameInput = "Andreas Johansson";
string emailInput = "[email protected]";
string passwordInput = "abcABC123";
string namePattern = @"^[A-z]+(-[A-z]+)*$";
string emailPattern = @"^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$";
string passwordPattern = @"^(?=.*\d+)(?=.*[a-zA-Z])[0-9a-zA-Z!@#$%]{6,50}$";
Regex nameRegEx = new Regex(namePattern);
Regex emailRegEx = new Regex(emailPattern);
Regex passwordRegEx = new Regex(passwordPattern);
if (model.CreateFullName.Length < 3 || !nameRegEx.IsMatch(nameInput))
isValid = false;
if (model.CreateEmail.Length < 3 || !emailRegEx.IsMatch(emailInput))
isValid = false;
if (model.CreatePassword.Length < 3 || !passwordRegEx.IsMatch(passwordInput))
isValid = false;
Thankful for inputs!