I used it in C#
var validString = new Regex(@"^[a-z][a-z\d!@#$%\^&*()\-+]{0,7}$(?<=\d\D+)", RegexOptions.Compiled);
I am trying to enforce the following rules for password creation
•Not have upper-case letters. •Begin with a letter. •Have at least 1 digit(s) not at the beginning and end. •Have up to 8 alphanumeric •Does NOT have any symbols like @#$ characters (symbols like !@#$%^&*()-+).
Any help would be appreciated
Almost identical, except for:
new RegExpinstead ofnew Regex@before the stringAlternatively use a regex literal:
Note I changed your regex, since you basically say you can’t have digits at the start or end. I used a lookahead instead to ensure there was a number in there.