See perlretut and perlre for the official documentation on this
In reply to Re: reg-ex pattern with nesting parethesis by Corion in thread reg-ex pattern with nesting parethesis by marscld