my $regex = qr{ # start of full pattern \( # match an opening parenthesis (?: 0 # everytime false, because of such DATA | # OR (?0) # recurse to capture full pattern )* \) # match a closing parenthesis # end of full pattern }x;