Skip to content

Instantly share code, notes, and snippets.

@onlyphantom
Last active May 24, 2019 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onlyphantom/e05d79508cb6a4b6148ac5dbe6b6b1fe to your computer and use it in GitHub Desktop.
Save onlyphantom/e05d79508cb6a4b6148ac5dbe6b6b1fe to your computer and use it in GitHub Desktop.
Regex to capture GitHub username/repo slug
# for username:
# Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen
# for repo url:
# any valid alphanumeric including underscores
import re
def validate_repo_url(value):
reg = re.compile('^([a-zA-Z\d]{1}[-a-zA-Z\d]+)(/){1}([\-\w]+)$')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment