Matches SemVer 2.0.0 strings.
Semantic Versioning helps validate values with a production-oriented regex baseline. Use it for fast client or backend checks, then add semantic validation and engine-specific tests before release. This reduces false positives while keeping implementation predictable across environments.
^v?(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-]+)*))?$Token-by-token with plain language, one sentence per token group.
| Input | Expected |
|---|---|
| 1.0.0 | Pass |
| 1.0.0-beta | Pass |
| Fail | |
| sample-value | Fail |
| test@example.com | Fail |
| 1234567890 | Pass |
Reference implementation.
Re-test lookbehind, unicode, and flags.
Prefer raw strings and explicit flags.
Double-escape backslashes in string literals.
Use this when you need a quick format validation or extraction step before business-level checks.
Core behavior is designed for broad compatibility, but always re-test flags and advanced groups in your target engine.
Avoid treating regex as the only safety check. Pair it with parser or domain-specific validation for production flows.