GitHub Repository URL
Match GitHub repository URLs and capture the owner and repo segments.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("https?:\\/\\/(?:www\\.)?github\\.com\\/([A-Za-z0-9](?:[A-Za-z0-9\\-]{0,38})?)\\/([A-Za-z0-9._\\-]{1,100})", "g");
const input = "Source at https://github.com/vercel/next.js or https://www.github.com/torvalds/linux";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9\-]{0,38})?)\/([A-Za-z0-9._\-]{1,100})")
input_text = "Source at https://github.com/vercel/next.js or https://www.github.com/torvalds/linux"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9\-]{0,38})?)\/([A-Za-z0-9._\-]{1,100})`)
input := `Source at https://github.com/vercel/next.js or https://www.github.com/torvalds/linux`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
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
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.