Identifiersflags: g
Semantic Version (SemVer)
Match semantic version strings like 1.2.3, 1.2.3-beta.1, or 1.2.3+build.42.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.]+)?(?:\+[\w.]+)? (flags: g)Raw source: (?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.]+)?(?:\+[\w.]+)?
How it works
Three numeric components (no leading zeros) separated by dots. Optional pre-release label after - and optional build metadata after + per the SemVer 2.0.0 spec.
Examples
Input
1.0.0Matches
1.0.0
Input
2.3.1-beta.1Matches
2.3.1-beta.1
Input
1.0.0+build.42Matches
1.0.0+build.42
Common use cases
- •Package version validation
- •Changelog parsing
- •Dependency version extraction
- •CI/CD pipeline version tagging
Related patterns
MongoDB ObjectId
IdentifiersMatch MongoDB ObjectId values — 24-character hexadecimal strings.
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Docker Image Tag
IdentifiersMatch Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.