Last active
May 24, 2019 10:51
-
-
Save onlyphantom/e05d79508cb6a4b6148ac5dbe6b6b1fe to your computer and use it in GitHub Desktop.
Regex to capture GitHub username/repo slug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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