use YAPE::Regex::Explain; $u= qr/(:?URL="([^"]*)")?/is; # optional clause (:?xxx)? print YAPE::Regex::Explain->new($u)->explain; __END__ The regular expression: (?is-mx:(:?URL="([^"]*)")?) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?is-mx: group, but do not capture (case-insensitive) (with . matching \n) (with ^ and $ matching normally) (matching whitespace and # normally): ---------------------------------------------------------------------- ( group and capture to \1 (optional (matching the most amount possible)): ---------------------------------------------------------------------- :? ':' (optional (matching the most amount possible)) ---------------------------------------------------------------------- URL=" 'URL="' ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- [^"]* any character except: '"' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- " '"' ---------------------------------------------------------------------- )? end of \1 (NOTE: because you're using a quantifier on this capture, only the LAST repetition of the captured pattern will be stored in \1) ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------