apologies my regex skills are lacking.
I'm using parsleyjs & I have this rule:
export const PASSWORD_RULE5 = /[\[\]@$!%*?&£€^(){}:"|<>/]{1}/;
This works. The rule is applied, if one of those characters does not appear in the password it highlights and warns them they need to add a special character.
the problem is the Input has a data_parsley_pattern :
data_parsley_pattern = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&£€^(){}:"|<>])[A-Za-z\\d!$%@#£€*?&]{8,}$"
This allows a password with
If they enter a ^
in their password, it no longer highlights, but the data_parsley_pattern still fails.
No matter what I try I cannot get this to work.
I've tried adding the new allowed special characters here & also tried escaping them, but the rule still fails.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&**£€^(){}:"|<>/**])[A-Za-z\\d!$%@#£€*?&]{8,}$
Or
^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&**£€\\^\\(\\)\\{\\}\\:\"\|\\<\\>\\/**])[A-Za-z\\d!$%@#£€*?&]{8,}$
Do I need to treat these characters differently?
Thanks for any insight.
Thanks to comments from @JvdV, I realised I was missing out my special characters in an important part of the regex.
Thanks To @Pradeep, the tool you provided in the comment is a massive help when testing Regex.
Another issue I had was that I am using ASP.Net MVC and an @Html.PasswordFor therefore the escape characters are slightly different.
Here's the solution for my issue above:
data_parsley_pattern = "^(?=. [az])(?=. [AZ])(?=. \d)(?=. [\\\"@$!% ?&£€^(){}:|<>/])[A-Za-z\d!$%@#£€ ?&^(){}\\\":|<>/]{8,}$"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.