Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for git repository

Tags:

What will be proper regular expression for git repositories?

example link: [email protected]:someone/someproject.git

so it will be like [user]@[server]:[project].git

server can be url or ip Project can contain some other characters than alphanumeric like '-' I'm not sure what is the role of '/'

any suggestions?

like image 862
dfens Avatar asked Mar 25 '10 11:03

dfens


1 Answers

I'm using the following regular expression for online remote repositories:

((git|ssh|http(s)?)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git)(/)?

View on Debuggex

Regular expression visualization

like image 191
Kel Solaar Avatar answered Oct 06 '22 00:10

Kel Solaar