Regular expression requirements:
-
from 3 to 5 characters,
-
at least one capital letter,
-
and at least one number.
My expression now looks like this.
The character limit does not work.
/((?=.*[A-Z])(?=.*\d)){3,5}/
>Solution :
{3,5} has to be after a pattern that matches something. You put it after lookaheads, which don’t match anything by themselves. Put a . before it to match a character. And you also need to anchor the regexp so it will match the entire input, not just part of it.
/((?=.*[A-Z])(?=.*\d))^.{3,5}$/