06. Validate Password от Regular Expressions
Здравейте,
на задача 6 от Regular Expressions, Exercise ми дава 77/100 като гърми на последните две проверки.
Може ли помощ къде греша?
Кодът ми:
https://pastebin.com/WFBu4tGL
06.Validate Password
Your first task is to determine if the given sequence of characters is a valid online banking password.
Each line must not contain anything else but a valid password. A password is valid when:
- It is surrounded by a "_" followed by one or more "."
- It is at least 6 characters long (without the surrounding "_" or ".")
- It starts with a capital letter
- It contains only letters (lower and upper case) and digits
- It ends with a capital letter
Examples of valid passwords: _...ChelseA_., _..Online1BankinG_., _.Valid1PasS_., _.A123f23A_.
Examples of invalid passwords: __InvalidPass.., _Invalid_, _.Invalid.IteM_., _.pass1InvaliD_.
Next, you have to determine which group the password is from. The group is obtained by concatenating all the digits found in the password, if any. If there are no digits present in the password, the default group is "default".
Examples:
_...ChelseA_. -> group: default
_..Online1BankinG_. -> group: 1
_.A123f23A_.-> group: 12323
Input
On the first line, you will be given an integer n – the count of passwords that you will be receiving next.
On the following n lines, you will receive different strings.
Output
For each password that you process, you need to print a message.
If the password is invalid:
- "Invalid pass!"
If the password is valid:
- "Group: {group}"