mirror of
https://github.com/semver/semver.git
synced 2026-03-11 00:12:22 -05:00
PreRelease denotation regular expression (regex) #96
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Oxymoron290 on GitHub (Aug 6, 2013).
I would like to verify my regex here is correct according to number 9 on the SemVer Specification.
^([-a-zA-Z0-9])([-a-zA-Z0-9\.](?<!\.{2}))*$(?<!\.)$Here are some tests I ran using C#.NET
and it's output:
@Oxymoron290 commented on GitHub (Aug 6, 2013):
also, would a pre-release in the format of
-.alphabe valid? I'm guessing not due to an empty identifier, however is the first alphanumeric string immediately after the hyphen an identifier?Additionally according to the specification a pre-release in the format of
--alpha.betawould be legal. Is this intended? It's strange but it appears to be allowed. Please correct me if I'm wrong on that.If not I suppose the expression could be updated to
^([-](?!\.))([-a-zA-Z0-9\.](?<!\.{2})(?<!\.0[0-9]))*$(?<!\.)$@robsimmons commented on GitHub (Aug 16, 2013):
-.alphashouldn't be valid, periods aren't identifiers so I'm not sure what you'd even consider the first alphanumeric string after the hyphen to be. Issue #147 talks about the leading hyphen issue (and references that it's been discussed before).@TimLovellSmith commented on GitHub (Oct 22, 2013):
-.alpha would be a violation of 'identifiers must NOT be empty'
@gvlx commented on GitHub (Oct 5, 2014):
This thread is still marked as open but it think it has been answered.
A newer discussion on regex patterns follows on https://github.com/mojombo/semver.org/issues/59