Regular Expressions 101

Community Patterns

semver 2.0.0 regex (named groups)

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
/
gm

Description

Semver 2.0.0 rwith named groups for those systems that support them (PCRE [Perl Compatible Regular Expressions, i.e. Perl, PHP and R], Python and Go). Source: https://semver.org/

Submitted by Soma Szelpal - 15 days ago (Last modified 15 days ago)