Regular Expressions 101

Community Patterns

Semantic Version

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?<Semantic>(?<Major>[0-9]+)\.(?<Minor>[0-9]+)(?:\.(?=[0-9]))?(?<Maintenance>[0-9]+)?(?:\.(?=[0-9]))?(?<Patch>[0-9]+)?)(?<Label>(?:(?:\.|\-|\+)?\w+)+)?
/
gm

Description

Matches and groups categories of semantic versions.

Submitted by Jon Stinnett - a year ago