Can conditionals be used to pair balance group elements?
问题 TL;DR: Is there a way to specify a conditional so that an opening element MUST match its paired closing element? Example is located on regex101.com. ===== Balancing elements in regex is typically handled through recursion. This means that nested {...{...{...}...}...} can be located. Also, PCRE allows the (?(DEFINE)...) construct, which lets you define various patterns without actually starting the match. In the regular expression # Define the opening and closing elements before the recursion