* 2 FETCH (UID 2 FLAGS (\Answered \Seen) INTERNALDATE "05-Jun-2008 07:19:01 +1000" RFC822.SIZE 5144 BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-1") NIL NIL "7bit" 2053 46 NIL ("inline" NIL) NIL NIL))
####
"UID" => "2",
"FLAGS" => "\Answered \Seen",
"INTERNALDATE" => "05-Jun-2008 07:19:01 +1000",
"RFC822.SIZE" => "5144",
"BODYSTRUCTURE" => "text" "plain" ("charset" "ISO-8859-1") NIL NIL "7bit" 2053 46 NIL ("inline" NIL) NIL NIL",
##
##
(?:
(?{ local $d=0 }) # set depth to 0
( # start capture
(?:
\( # opening paren
(?{$d++}) # increment the depth
|
\) # or closing paren
(?{$d--}) # decrement the depth
(?(?{$d==0}) # if we're back to the start
(*ACCEPT) # we're done
)
|
(?>[^()]*) # or there's just some normal text
)*
(?(?{$d!=0}) # done. did we reach a matching closing paren
(?!) # nope, failed
)
) # end capture
)