Tuesday 15 January 2013

c# - Regex for git's repository -



c# - Regex for git's repository -

i want utilize regex validate git repository url. found few answers on stackoverflow none of them passes tests.

the debug here: http://regexr.com/39qia

how can create passes lastly 4 cases?

git@git.host.hy:group-name/project-name.git git@git.ho-st.hy:group-name/project-name.git http://host.xy/agroup-name/project-name.git http://ho-st.xy/agroup-name/project-name.git

i can't since i'm not familiar git link syntaxes, next regex additionally match 4 next values:

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

i have indicated changed parts; namely:

added - part after @ because ho-st not passing otherwise. moved - end of character class because otherwise /-~ mean character range / ~ matches lot of characters. escaped final dot (thanks @maticicero)

there lot of things simplified above, since don't know exact goals, i'm leaving regex close possible 1 have.

c# regex

No comments:

Post a Comment