[GH-ISSUE #624] Regex examples contain invalid semvers as valid semvers #1304

Closed
opened 2026-04-16 10:40:56 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @sschuberth on GitHub (Oct 11, 2020).
Original GitHub issue: https://github.com/semver/semver/issues/624

My understanding from reading 9., looking at the BNF and reading comment like this is that if there is both a pre-release and build meta data part, the pre-release part has to come first. Still, the online regexes contain e.g. 1.1.2+meta-valid as a valid semver, whereas it IMO should be 1.1.2-valid+meta.

Originally created by @sschuberth on GitHub (Oct 11, 2020). Original GitHub issue: https://github.com/semver/semver/issues/624 My understanding from reading [9.](https://semver.org/#spec-item-9), looking at the [BNF](https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions) and reading comment like [this](https://github.com/semver/semver/issues/45#issuecomment-8173992) is that *if* there is both a pre-release and build meta data part, the pre-release part has to come first. Still, the [online](https://regex101.com/r/Ly7O1x/3/) [regexes](https://regex101.com/r/vkijKf/1/) contain e.g. `1.1.2+meta-valid` as a valid semver, whereas it IMO should be `1.1.2-valid+meta`.
Author
Owner

@klehelley commented on GitHub (Oct 12, 2020):

Hyphens are allowed in build metadata. As a consequence, 1.1.2+meta-valid is a valid SemVer string, and should be interpreted as such:

  • Major : 1
  • Minor : 1
  • Patch : 2
  • Pre-release : (none)
  • Build metadata : meta-valid
<!-- gh-comment-id:706948228 --> @klehelley commented on GitHub (Oct 12, 2020): Hyphens are allowed in build metadata. As a consequence, `1.1.2+meta-valid` is a valid SemVer string, and should be interpreted as such: * Major : `1` * Minor : `1` * Patch : `2` * Pre-release : (none) * Build metadata : `meta-valid`
Author
Owner

@sschuberth commented on GitHub (Oct 12, 2020):

Thanks for the clarification. I was confused by <build identifier> ::= <alphanumeric identifier> ... as I though it's clear that "alphanumeric" are just letters and digits, but in fact it is <alphanumeric identifier> ::= <non-digit> ..., and <non-digit> includes "-".

<!-- gh-comment-id:707023095 --> @sschuberth commented on GitHub (Oct 12, 2020): Thanks for the clarification. I was confused by `<build identifier> ::= <alphanumeric identifier> ...` as I though it's clear that "alphanumeric" are just letters and digits, but in fact it is `<alphanumeric identifier> ::= <non-digit> ...`, and `<non-digit>` includes `"-"`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#1304