![]() |
VOOZH | about |
Given a password string, the task is to check whether it is strong or weak based on a set of conditions. A password is considered strong only if it passes all rules below:
For Examples:
Input: Qggf!@ghf3
Output: Strong Password!
Input: aaabnil1gu
Output: Weak Password -> Same character repeats three or more times in a row
Let’s explore different methods to validate password strength.
This method uses one comprehensive regex pattern that checks password length, repeating characters, and repeating patterns in a single match. If the entire password matches the pattern, it is considered strong.
Strong Password!
Explanation:
Instead of one big regex, this method checks each rule separately using smaller regular expressions. If any check fails, the corresponding message is printed.
Strong Password!
Explanation:
This method uses a simple loop to detect 3 repeated characters and regex to detect repeating substring patterns. It is slower than full-regex but easier to understand.
Weak Password: Same character repeats three or more times in a row
Explanation:
This method manually checks length, spaces, repeated characters, and substring repetition without relying on regex. It is the slowest and mainly educational.
Strong Password!
Explanation: