Are these valid version numbers:
1.0.0-0 (not a leading zero, but just a zero as pre-release version identifier)
1.0.0+some.build.metadata-beta (pre-release version identifier and build metadata swapped)
I understand these versions are rare, but according the standard they are valid. (if read literally).I have to write a regex, so this need to be clarified.
Originally created by @BartG95 on GitHub (Aug 19, 2015).
Original GitHub issue: https://github.com/semver/semver/issues/266
Are these valid version numbers:
1.0.0-0 (not a leading zero, but just a zero as pre-release version identifier)
1.0.0+some.build.metadata-beta (pre-release version identifier and build metadata swapped)
I understand these versions are rare, but according the standard they are valid. (if read literally).I have to write a regex, so this need to be clarified.
1.0.0-0 is valid; the pre-release indentifier would be interpreted as non-numeric and cause lexicographical comparison with a different version it's just a zero. 1.0.0+some.build.metadata-beta is valid; -beta is part of the medatata-beta identifier, which in turn is part of the build metadata.
<!-- gh-comment-id:132852028 -->
@FichteFoll commented on GitHub (Aug 20, 2015):
`1.0.0-0` is valid; ~~the pre-release indentifier would be interpreted as non-numeric and cause lexicographical comparison with a different version~~ it's just a zero.
`1.0.0+some.build.metadata-beta` is valid; `-beta` is part of the `medatata-beta` identifier, which in turn is part of the build metadata.
@DavidFichtmueller commented on GitHub (Aug 20, 2015):
I agree, both are valid. If you need a RegEx to check, you can use this one: #232 . I hope this helps.
<!-- gh-comment-id:132930282 -->
@DavidFichtmueller commented on GitHub (Aug 20, 2015):
I agree, both are valid. If you need a RegEx to check, you can use this one: #232 . I hope this helps.
<!-- gh-comment-id:133546945 -->
@BartG95 commented on GitHub (Aug 21, 2015):
Thanks! I already made an RegEx. According to that RegEx both are valid, I just wanted to make sure it is correct.
For completeness, here's my RegEx:
```
(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(((0|[1-9]\d*)|[1-9A-Za-z-][0-9A-Za-z-]*)\.)*((0|[1-9]\d*)|[1-9A-Za-z-][0-9A-Za-z-]*))?(\+(([0-9A-Za-z-]+)\.)*([0-9A-Za-z-]+))?
```
@DavidFichtmueller commented on GitHub (Aug 26, 2015):
Hey BartG95,
I compared your RegEx against mine and found one difference, where I think yours is not confirming to the specs. In section 9 (pre -release version):
Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes.
The way I understand this, is that only pure numerical identifiers must not have a leading zero, but identifiers that are a mixture between numbers and letters can have a leading zero. So according to the specification 1.42.0-rc.0-bugs-remaining is a valid semver number, but it will not be (completely) captured by your RegEx.
This is a minor thing, but I noticed it and wanted to let you know.
Cheers
David
<!-- gh-comment-id:134925794 -->
@DavidFichtmueller commented on GitHub (Aug 26, 2015):
Hey BartG95,
I compared your RegEx against mine and found one difference, where I think yours is not confirming to the specs. In section 9 (pre -release version):
> Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes.
The way I understand this, is that only pure numerical identifiers must not have a leading zero, but identifiers that are a mixture between numbers and letters can have a leading zero. So according to the specification `1.42.0-rc.0-bugs-remaining` is a valid semver number, but it will not be (completely) captured by your RegEx.
This is a minor thing, but I noticed it and wanted to let you know.
Cheers
David
Thanks. I should have looked to this before: https://github.com/mojombo/semver/blob/master/semver.svg
I've update my RegEx to this: (0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))\.)*(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))))?(?:\+((?:(?:[0-9A-Za-z-]+)\.)*[0-9A-Za-z-]+))? (http://regexr.com/3bm59)
I also included non-capturing groups, which make it is easier to parse a version.
<!-- gh-comment-id:135765386 -->
@BartG95 commented on GitHub (Aug 28, 2015):
Thanks. I should have looked to this before: https://github.com/mojombo/semver/blob/master/semver.svg
I've update my RegEx to this:
`(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))\.)*(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))))?(?:\+((?:(?:[0-9A-Za-z-]+)\.)*[0-9A-Za-z-]+))?` (http://regexr.com/3bm59)
I also included non-capturing groups, which make it is easier to parse a version.
@DavidFichtmueller commented on GitHub (Aug 28, 2015):
Looks good. Nice use of non-capturing groups. And just in case you don't already know this classic, here is the XKCD about Regular Expressions: http://www.xkcd.com/208/ . Cheers.
<!-- gh-comment-id:135798799 -->
@DavidFichtmueller commented on GitHub (Aug 28, 2015):
Looks good. Nice use of non-capturing groups. And just in case you don't already know this classic, here is the XKCD about Regular Expressions: http://www.xkcd.com/208/ . Cheers.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @BartG95 on GitHub (Aug 19, 2015).
Original GitHub issue: https://github.com/semver/semver/issues/266
Are these valid version numbers:
1.0.0-0 (not a leading zero, but just a zero as pre-release version identifier)
1.0.0+some.build.metadata-beta (pre-release version identifier and build metadata swapped)
I understand these versions are rare, but according the standard they are valid. (if read literally).I have to write a regex, so this need to be clarified.
@FichteFoll commented on GitHub (Aug 20, 2015):
1.0.0-0is valid;the pre-release indentifier would be interpreted as non-numeric and cause lexicographical comparison with a different versionit's just a zero.1.0.0+some.build.metadata-betais valid;-betais part of themedatata-betaidentifier, which in turn is part of the build metadata.@DavidFichtmueller commented on GitHub (Aug 20, 2015):
I agree, both are valid. If you need a RegEx to check, you can use this one: #232 . I hope this helps.
@BartG95 commented on GitHub (Aug 21, 2015):
Thanks! I already made an RegEx. According to that RegEx both are valid, I just wanted to make sure it is correct.
For completeness, here's my RegEx:
@DavidFichtmueller commented on GitHub (Aug 26, 2015):
Hey BartG95,
I compared your RegEx against mine and found one difference, where I think yours is not confirming to the specs. In section 9 (pre -release version):
The way I understand this, is that only pure numerical identifiers must not have a leading zero, but identifiers that are a mixture between numbers and letters can have a leading zero. So according to the specification
1.42.0-rc.0-bugs-remainingis a valid semver number, but it will not be (completely) captured by your RegEx.This is a minor thing, but I noticed it and wanted to let you know.
Cheers
David
@BartG95 commented on GitHub (Aug 28, 2015):
Thanks. I should have looked to this before: https://github.com/mojombo/semver/blob/master/semver.svg
I've update my RegEx to this:
(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))\.)*(?:\d*[A-Za-z-][0-9A-Za-z-]*|(?:0|[1-9]\d*))))?(?:\+((?:(?:[0-9A-Za-z-]+)\.)*[0-9A-Za-z-]+))?(http://regexr.com/3bm59)I also included non-capturing groups, which make it is easier to parse a version.
@DavidFichtmueller commented on GitHub (Aug 28, 2015):
Looks good. Nice use of non-capturing groups. And just in case you don't already know this classic, here is the XKCD about Regular Expressions: http://www.xkcd.com/208/ . Cheers.