use Modern::Perl; use YAPE::Regex::Explain; my $fieldname = 'SomeTag'; say YAPE::Regex::Explain->new(qr|<$fieldname>(.*?)|i)->explain(); #### The regular expression: (?i-msx:(.*?)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?i-msx: group, but do not capture (case-insensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- '' ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- '' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------