Created
January 22, 2022 01:53
-
-
Save japharr/afb97f5830933e46cca7651196e2b3fe to your computer and use it in GitHub Desktop.
Username regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$ | |
^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$ | |
└─────┬────┘└───┬──┘└─────┬─────┘└─────┬─────┘ └───┬───┘ | |
│ │ │ │ no _ or . at the end | |
│ │ │ │ | |
│ │ │ allowed characters | |
│ │ │ | |
│ │ no __ or _. or ._ or .. inside | |
│ │ | |
│ no _ or . at the beginning | |
│ | |
username is 8-20 characters long | |
If your browser raises an error due to lack of negative look-behind support, use the following alternative pattern: | |
^(?=[a-zA-Z0-9._]{8,20}$)(?!.*[_.]{2})[^_.].*[^_.]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment