Webflags: g
GitHub Repository URL
Match GitHub repository URLs and capture the owner and repo segments.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9\-]{0,38})?)\/([A-Za-z0-9._\-]{1,100}) (flags: g)Raw source: https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9\-]{0,38})?)\/([A-Za-z0-9._\-]{1,100})
How it works
https?:\/\/(?:www\.)?github\.com\/ matches the domain with optional www and either http/https. The first capture ([A-Za-z0-9](?:[A-Za-z0-9\-]{0,38})?) follows GitHub's username rules: 1–39 chars, alphanumeric + hyphens, no leading/trailing hyphen (simplified). The second capture matches the repo name with the broader allowed character set.
Examples
Input
Source at https://github.com/vercel/next.js or https://www.github.com/torvalds/linuxMatches
https://github.com/vercel/next.jshttps://www.github.com/torvalds/linux
Input
Star: https://github.com/anthropics/claude-codeMatches
https://github.com/anthropics/claude-code
Input
no github linksNo match
—Common use cases
- •README / docs link extraction
- •Dependency source resolution
- •Citing repositories in academic / blog content
- •Building star/fork dashboards from text input
Related patterns
LinkedIn Profile URL
WebMatch LinkedIn profile URLs and capture the profile slug.
Twitter / X URL
WebMatch Twitter/X profile and status URLs, capturing the handle and (optional) tweet ID.
URL Validation
WebMatch http and https URLs with optional www prefix, paths, query strings, and fragments.
YouTube Video ID
WebExtract 11-character YouTube video IDs from long URLs, short URLs, or embed URLs.