TL;DR: here is the glob pattern: @(0|[1-9]*([0-9])).@(0|[1-9]*([0-9])).@(0|[1-9]*([0-9]))?(-@(*([0-9])[a-zA-Z-]*([a-zA-Z0-9-])|@(0|[1-9]*([0-9])))*(.@(*([0-9])[a-zA-Z-]*([a-zA-Z0-9-])|@(0|[1-9]*([0-9])))))?(++([a-zA-Z0-9-])*(.+([a-zA-Z0-9-])))
This project aims to detect precisely versions following semver 2.0. The generation code is based on Backusnaur form grammar defined in semver 2.0.
A complete test can be found at Glob Tool, an online glob testing utility.
In order to test locally, run the following commands:
npm install
npm generate
Feel free to improve the generation, as the glob pattern currently is 210 characters long.