Notation (?: ), group but do not capture Perl =~ links m/.../ with the string if ($s =~ m/^([0-9]+) (?:[CF])$/) print $1