Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\.[0-9]{1,3})?(\-(alpha|beta|preview|rc))?(\.[0-9]{1,3})?$
/
gm

Description

Check software versioning with semVer rules. Accept:

  • Major.Minor.Patch: 1.2.3
  • Major.Minor.Patch.Build: 1.2.3.4
  • Major.Minor.Patch-(pre-release): 1.2.3-beta
  • Major.Minor.Patch-(pre-release).Build: 1.2.3-alpha.1
Submitted by fabman08 - 3 years ago