public override bool Validate(string line) { PasswordWithSpec pws = ExtractPasswordWithSpec(line); var count = pws.Password.Count(c => c == pws.Character); return(count >= pws.Low && count <= pws.High); }
protected static PasswordWithSpec ExtractPasswordWithSpec(string line) { var groups = Pattern.Matches(line).First().Groups; PasswordWithSpec pw = new PasswordWithSpec() { Low = int.Parse(groups[1].ToString()), High = int.Parse(groups[2].ToString()), Character = groups[3].ToString().ToCharArray()[0], Password = groups[4].ToString(), }; return(pw); }