Regex ninjas help

to any regex ninja out there.
I’m trying to make a regex to grab only the repository name from different git urls

example inputs

example outputs


the one I’m working now is simple, but there is something missing there, the result is outputting ofxSyphon.git instead of ofxSyphon

	std::regex findRepository("([^/]+)(\.git)?$");

Thank you!

Hey @dimitre,
Here’s one that I just wrote, I hope it fits your needs.


I tested it on RegexR with some extra git hosts just in case.
If you don’t know that site, I recommend it, it explains regexes very well.
I didn’t test it in c++, sometimes there can be slight differences.

Or, if you only want the 4th group :

1 Like

Thank you! works great