The semver shape
Semantic Versioning is the MAJOR.MINOR.PATCH format that anchors most software releases. The basic regex:
^\d+\.\d+\.\d+$
Three numeric parts joined by dots. 1.0.0 matches; 1.0 doesn't.
The full semver pattern
Real semver allows pre-release suffixes (1.0.0-alpha, 1.0.0-rc.1) and build metadata (1.0.0+build.123). The official regex from the semver spec:
^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
Yes, that's the official one. Yes, you should look it up rather than memorize it. The README of the semver spec on GitHub has it.
For ad-hoc usage
Most of the time you don't need full semver — you need "matches a version-shape thing." The simple \d+\.\d+\.\d+ covers most cases.
Comparing versions
Don't compare versions with regex — extract the parts, then compare numerically. Python: packaging.version.parse. Node: semver npm package. Go: standard library handling.