Regexdrill

Level 5: Advanced Exercise 49 of 52 Pro

Password rules with lookaheads

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

The whole line must match. A valid password has at least 8 characters, no spaces, and at least one lowercase letter, one uppercase letter and one digit, in any order.

What this exercise teaches

(?=.*[a-z])(?=.*[A-Z])(?=.*\d)\S{8,} checks each rule from the start of the line, then requires 8 or more non-space characters.

A hint if you get stuck

Stack one lookahead per rule at the start, like (?=.*[a-z]), then match the allowed characters.

This exercise is part of Pro

Pro unlocks all 52 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Advanced