host:prompt> perl -MYape::Regex::Explain -le " my $p = YAPE::Regex::Explain->new(qr{^KG\d{3}[JMA]$}); print $p->explain();" The regular expression: (?-imsx:^KG\d{3}[JMA]$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- KG 'KG' ---------------------------------------------------------------------- \d{3} digits (0-9) (3 times) ---------------------------------------------------------------------- [JMA] any character of: 'J', 'M', 'A' ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------