r/pythonhelp • u/thecrumpetman • Jan 04 '19
Python Regex GitLab Repo URL Matching
Hey all. I'm having an issue with my regular expression in Python and was hoping somebody could help. This is what I have so far:
git_url = re.compile(r'([\w+@\:/\-~]+\.git)')
This returns both:
https://gitlab.aa.bb.cc.dd/username/repo-name.git # repo names could included - or _
[email protected]/username/repo-name.gitI basically want the possibility of either, so I can select using a script. To give some context, this Python script uses the GitLab API and clones all repositories based on the username specified. The second part of the script reads:
[..]
for url in re.findall(git_url, group_attr): # group_attr is a list of group attributes
subprocess.call(['git', 'clone', url])Any help is much appreciated :-)
0
Upvotes
1
u/acecile Jan 05 '19
I dont really understand your issue but what I'm pretty sure if is that you don't want regex parsing the find the cloning URI. Check GitLab API again there must be a field returning this.