$re = '/^( {3})+/m';
$str = '      EMPTY_CNT :
      for i in 0 to C_DESCRIPTOR_NUM - 1 loop
         if r.descriptor_array(i).descriptor_state = S_READ_TO_DUMP then
            v.dump_in_progress_cnt := v.dump_in_progress_cnt + 1;
         end if;
      end loop;  -- i
entity descriptor_manager is
   port (
      i_clk                      : in  std_logic;
      i_rst                      : in  std_logic;
      i_desc_mngr                : in  t_i_desc_mngr;
      o_desc_mngr                : out t_o_desc_mngr;
      -- c/s registers
      cr_descriptor_select       : in  std_logic_vector(31 downto 0);
      cr_descriptor_data         : out std_logic_vector(31 downto 0);
      fsm_descriptor_ctrl_status : out std_logic_vector(31 downto 0);
      fsm_event_handler_status   : out std_logic_vector(31 downto 0)
      );
end entity descriptor_manager;';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php