Advanced Regular Expression Patterns
Noncapturing Groups
Noncapturing groups organize alternatives without creating extra capture values.
Noncapturing Groups
noncapturing_groups.pl
use strict;
use warnings;
my $word = ;
my $matched = $word =~ /^col(?:ou)?r$/;
my $status = $matched ? "spelling" : "other";
print "word=$word\n";
print "matched=$matched\n";
print "status=$status\n";
use strict;
use warnings;
my $word = ;
my $matched = $word =~ /^col(?:ou)?r$/;
my $status = $matched ? "spelling" : "other";
print "word=$word\n";
print "matched=$matched\n";
print "status=$status\n";
use strict;
use warnings;
my $word = ;
my $matched = $word =~ /^col(?:ou)?r$/;
my $status = $matched ? "spelling" : "other";
print "word=$word\n";
print "matched=$matched\n";
print "status=$status\n";
noncapturing-groups
Use a noncapturing group when grouping controls the pattern but the grouped text is not a value the program needs later.