100% Client-Side β’ 0 B Data Leaves Browser
web
GitHub Username Regex
Strictly complies with GitHub username rules: max 39 chars, alphanumeric, single internal hyphens, no consecutive hyphens, cannot start or end with a hyphen.
Regular Expression Pattern:
/^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/
Valid Match Example:
ensibey
Invalid / Non-Match Example:
-invalid-name
Regex Syntax Breakdown & Explanation
- β’^[a-zA-Z0-9] : Must begin with alphanumeric character
- β’-(?=[a-zA-Z0-9]) : Hyphens permitted only if followed immediately by alphanumeric (no consecutive hyphens)
- β’{0,38}$ : Total length capped at 39 characters
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;
const isValid = regex.test("ensibey");
console.log(isValid); // truePython (re)
import re
pattern = r"^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$"
match = re.match(pattern, "ensibey")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$`)
fmt.Println(re.MatchString("ensibey"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/. Strictly complies with GitHub username rules: max 39 chars, alphanumeric, single internal hyphens, no consecutive hyphens, cannot start or end with a hyphen.