Capturing text before and after a C-style code block with a Perl regular expression
Capture groups are numbered left-to-right in the order they occur in the regex, not in the order they are matched. Here is a simplified view of your regex: m/ (.+?) # group 1 (?: # the $code_block regex (?&block) (?(DEFINE) (?<block> … ) # group 2 ) ) (.+) # group 3 /xs Named groups … Read more