use strict;
my $str = 'Inspired by Semantic Release Distributions Channels from Branches: https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches
Valid Semantic Release Distribution Channels:
0.0.x
0.x.x
0.x
1.2.x
1.x.x
1.x
10.20.x
10.x.x
10.x
1.0.x
2.0.x
2.x.x
2.x
1.1.x
99999999999999999999999.999999999999999999.x
99999999999999999999999.x.x
99999999999999999999999.x
main
next
next-major
beta
alpha
Inalid Semantic Release Distribution Channels:
x
0.
0.xx
00.0.x
1.2
01.x
1.02.x
1.x.0
x.20.x
x.x.x
x.0.x
2.0.x-alpha
2.0.x+meta
x.x
01.1.x
99999999999999999999999.0999999999999999999.x
099999999999999999999999.x.x
mains
pre-next
next-minor
beta+
-alpha
gamma
';
my $regex = qr/^(((0|[1-9]\d*)\.)(((0|[1-9]\d*|x)\.)?x)|main|next(-major)?|beta|alpha)$/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html