^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$
- Semantic versioning http://semver.org/
- Source of the regex npm/node-semver#32
^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$
@Tschebbischeff Yeah, I stared at it for a while but I figured "If I can't do an ls
for that pattern, I can't do this". Oh well, at least I can block off v*
...and hope no bosses want a v-tag! 😄
@mathomp4
It is impossible to create a pattern for semver strings with the glob-style pattern matching emmaviolet@github mentioned they use.
I'm sorry 😔
More detail if you want:
A semver string's major version part alone allows for a theoretically infinite string of numerical characters. Let's try to get the equivalent of the regex
[0-9]*
only.*
allows any string (excl./
maybe, then**
specifically would allow/
inside).It is limitable with a constant prefix, infix or suffix, but there is no way to limit the "type of character" it allows at the beginning and/ or end of the string.
Now
*
and**
are the only two special characters that allow to match more than one character.There is no way to make
?
or[set]
match against more than one character and{a,b}
(if even available here) is based ona
andb
being patterns. Those patterns might allow infinite strings by using*
inside, but do not allow limiting the type of character for the same reason as above.Hence, it's not possible to match "an infinite string comprised of only specific characters" in glob-style 🥲