Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Python

r"
^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>alpha|beta|rc)(?:\.(?P<version>0|[1-9]\d*))?)?$
"
gm

Description

Given a version number MAJOR.MINOR.PATCH, increment the:

  1. MAJOR version when you make incompatible API changes.
  2. MINOR version when you add functionality in a backward compatible manner.
  3. PATCH version when you make backward compatible bug fixes.

A pre-release version MAY be denoted by appending a hyphen and a dot-separated identifier immediately following the patch version, e.g. "1.0.0-alpha" or "1.0.0-alpha.1".

Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.2 < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 < 2.0.0.

Submitted by FranEnguix - 2 months ago (Last modified 2 months ago)