use YAPE::Regex::Explain; print YAPE::Regex::Explain ->new( qr/\[(\/?)(lien|url|citation|img).+?\]/s )->explain; __END__ The regular expression: (?s-imx:\[(/?)(lien|url|citation|img).+?\]) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?s-imx: group, but do not capture (with . matching \n) (case-sensitive) (with ^ and $ matching normally) (matching whitespace and # normally): ---------------------------------------------------------------------- \[ '[' ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- /? '/' (optional (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- lien 'lien' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- url 'url' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- citation 'citation' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- img 'img' ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- .+? any character (1 or more times (matching the least amount possible)) ---------------------------------------------------------------------- \] ']' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------