I want to set a password which do not allow specific special characters like
-_\
and my regular expression is as follows
PatternCompiler compiler = new Perl5Compiler();
PatternMatcher matcher = new Perl5Matcher();
pattern = compiler.compile("^(?=.*?[a-zA-Z])(?=.*?[0-9])([A-Za-z0-9-/-~][^\\\\\\\\_\-]*)$");
It is working partially. If i place unwanted special characters between the string and start of the string still it is matching the password
P@ssword123 --correct
-password@123 --it should not match
-passowrd"11 --it should not match
\password123 --it should not match
_@111Password --it should not match
p@sswor"123 --correct
Any where in the string if i find -_\ regular expression should not match. Using Apache api for matching pattern in java