I need to verify a password using reqex. I have written one and tested it in this checker and it works:
http://www.nvcc.edu/home/drodgers/ceu/resources/test_regexp.asp
But when I add it to my Java application, it fails.
Regex in regex checker:(\D+)(\d+)(\D+)(.*)
Regex in java: (\\D+)(\\d+)(\\D+)(.*)
Test string: 1Hello2
This passes in the online checker but fails in Java.
Does anyone know why?
I want the regex to match any password that has a number in its middle (can have them at the start and end too).
I need 2 seperate regex: one that matches digits in the middle (pass1word or 1pass1word or 1pass1word) and also a regex that matches a digit at the start or end (1password or password1 NOT pass1word1 because that is in the string category).
Your regex requres:
Your example contains
I think it is obvious that it does not match the regex: the first element \D+ fails because digit appears in the beginning.