Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^ (?<Major>0|[1-9]\d*)\. (?<Minor>0|[1-9]\d*)\. (?<Patch>0|[1-9]\d*) (?<PreReleaseTagWithSeparator>-(?<PreleaseTag>(0|[1-9]\d*|[a-z-][\da-z-]*|[\da-z-]+[a-z-][\d-az-]*)(\.(0|[1-9]\d*|[a-z-][\da-z-]*|[\da-z-]+[a-z-][\d-az-]*))*))? (?<BuildMetadataWithSeparator>\+(?<BuildMetadata>(\d+|[a-z-][\da-z-]*|[\da-z-]+[a-z-][\d-az-]*)(\.(\d+|[a-z-][\da-z-]*|[\da-z-]+[a-z-][\d-az-]*))*))? $
/
gmix

Description

Matches SemVer 2.0 version strings.

Submitted by anonymous - 5 years ago