mardi 1 mai 2018

{REGEX} Username

I'm trying to create a regex pattern to validate the following username(s) and nothing else:

Usernames must be between 1 and 12 characters long.
Usernames may only contain alphanumeric characters, the space, and hyphens (-). Any other characters are replaced with a space.
Usernames cannot start with or end with a space, but can have any number of spaces between.
Given the above parameters, there are 2,084,454,322,680,818,585,575,401,523,200 possible usernames.

I don't know where to start but I'd love to receive some hints or even better a working pattern.

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire