Underbraces in Matrix Divided in Blocks

Here's another (TikZ-free) option:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}

\newcommand\undermat[2]{%
  \makebox[0pt][l]{$\smash{\underbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}_{\text{$#1$}}}$}#2}

\begin{document}

\[
\left (
\begin{array}{rrr|rrr}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
\undermat{A}{0 & 0 & 0} & \undermat{B}{0 & 0 & 0} \\
\end{array}
\right )
\]

\end{document}

enter image description here


Your code was not a minimal working example (MWE) (It's missing \begin{document} and \end{document}. Please make it a habit to provide one.

You should really consider using the \tikzmark macro for this. There are already a lot of answers regarding this tikz-based macro on this site. (AFAIK, a package is on the way to completion based on this macro by Andrew Stacey. For instance you can read the related question: \underbrace at a strange place, spanning array columns which you can tailor to the code below:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=(#1.base)]
  \node (#1) {\strut};}
\begin{document}
\[
\left (
\begin{array}{rrr|rrr}
0 & 0 & 0 &\tikzmark{upper1} 0 & 0 & 0\tikzmark{upper2} \\
0 & 0 & 0 & 0 & 0 & 0 \\
\tikzmark{lower1}0 & 0 & 0\tikzmark{lower2} & 0 & 0 & 0 \\
\end{array}
\right )
\]

\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=5pt}]
\draw[decorate,thick] (lower2.south) -- (lower1.south)
      node [midway,below=5pt] {Left block};
\draw[decorate,thick] (upper1.north) -- (upper2.north)
      node [midway,above=5pt] {Right block};
\end{tikzpicture}
\end{document}

enter image description here

You have to compile this twice to see the same output.