I've written the following regular expression to verify that a string is a valid version according to MAJOR.MINOR.PATCH-PREREL, i.e. excluding the build metadata part:
I would appreciate it if this regular expression becomes part of the specification or at least the FAQ.
Originally created by @timfriske on GitHub (May 20, 2014).
Original GitHub issue: https://github.com/semver/semver/issues/199
Hi,
I've written the following regular expression to verify that a string is a valid version according to MAJOR.MINOR.PATCH-PREREL, i.e. excluding the build metadata part:
```
^(?!0\d)\d+(?:\.(?!0\d)\d+){2}(?:-(?:(?!0\d)(?:(?!_)[\w-])+|\.(?!\.|$))+)?$
```
I would appreciate it if this regular expression becomes part of the specification or at least the FAQ.
I included some line breaks for "readability" - these should obviously be removed if the expression is used in code.
<!-- gh-comment-id:43640395 -->
@damianpowell commented on GitHub (May 20, 2014):
You could fairly trivially validate the build metadata too. It is part of the spec, after all.
```
^
(?!0\d)\d+(?:\.(?!0\d)\d+){2}
(?:-(?:(?!0\d)(?:(?!_)[\w-])+|\.(?!\.|$))+)?
(?:\+(?:(?:(?!_)[\w-])+|\.(?!\.|$))+)?
$
```
I included some line breaks for "readability" - these should obviously be removed if the expression is used in code.
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 @timfriske on GitHub (May 20, 2014).
Original GitHub issue: https://github.com/semver/semver/issues/199
Hi,
I've written the following regular expression to verify that a string is a valid version according to MAJOR.MINOR.PATCH-PREREL, i.e. excluding the build metadata part:
I would appreciate it if this regular expression becomes part of the specification or at least the FAQ.
@damianpowell commented on GitHub (May 20, 2014):
You could fairly trivially validate the build metadata too. It is part of the spec, after all.
I included some line breaks for "readability" - these should obviously be removed if the expression is used in code.
@FichteFoll commented on GitHub (May 20, 2014):
https://github.com/mojombo/semver/issues/192#issuecomment-40935547
@haacked commented on GitHub (Jul 1, 2014):
Looks like this question was answered. If not, feel free to reopen.