Regex for username
/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/gm
Matches
Examples
Note
Starts with a letter, then 3–16 characters in total of letters, digits and underscores. Adjust the {2,15} for other lengths.
Matches in the example
"ana_92""Bob"
Token by token
^the start of the string (or line, with the m flag)[a-zA-Z]one of: “a” to “z” or “A” to “Z”[a-zA-Z0-9_]{2,15}one of: “a” to “z”, “A” to “Z”, “0” to “9” or “_”, between 2 and 15 times, as many as possible$the end of the string (or line, with the m flag)
Other patterns
- Email address
- URL
- IPv4 address
- UUID
- Hex color
- Date (YYYY-MM-DD)
- Time (24-hour)
- US phone number
- Phone number (E.164)
- US ZIP code
- Credit card number
- URL slug
- Username
- Strong password
- HTML tag
- Semantic version
- MAC address
- JSON Web Token
- Hashtag
- @mention
- Number
- Leading and trailing whitespace
- Repeated word
- Blank lines
- Markdown link
- Quoted string
- Domain name
- File extension
- Base64
- Trailing comma