$foo =~ /( ( :? . # 0 or 1 colon + 1 non-newline char | # or \n (?! \n\n) # 1 newline not followed by two more newlines )+ ) /x