Restrict Possible Usernames - one last user story to go!

My Problem:

I went user story by user story and now my code fulfills all but one user stories. My regex does not match “Z97” because {2,} requires at least 2 letters at the beginning, but if I change it to the quantifier + instead, 2 other user stories are not being fulfilled anymore… I am trying to figure this out since hours and I am not sure if my code is a dead end… Can anybody give me a hint?

This is my code so far:

/^[a-zA-Z]{2,}\d*$/

Challenge:

My hint would be to check again the first few challenges in the regex section, to be precise the third one

1 Like

Thank you so much! I was able to match Z97 now with the following regex:
/(^[a-zA-Z])([a-zA-Z]|[0-9]{2,}$)/
Unfortunately, the regex matches BadUs3rnam3 now, because the first a of BadUs3rnam3 is matched with the first option of the second capturing group and I feel like I am back to where I was yesterday :smiley:
I am determined to figure this out soon!

You are almost there, you need to consider well what can go at the beginning, what can go at the end, and what can go in the middle

Your first option matches two letters at the beginning of the string - but what about the rest?

The second one matches a string of length three with pattern letter, number, number

1 Like

Omg, I actually solved it :smiley: Can’t believe it :smiley: Thank you so much.

1 Like