title: RegEx syntax for multiline
body: <p>This is a snippet of a file I am trying to parse.</p>
  
  <pre><code>typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RC1REGbits_t;
  extern volatile RC1REGbits_t RC1REGbits __at(0x119);
  // bitfield macros
  #define _RC1REG_RC1REG_POSN                                 0x0
  #define _RC1REG_RC1REG_POSITION                             0x0
  #define _RC1REG_RC1REG_SIZE                                 0x8
  #define _RC1REG_RC1REG_LENGTH                               0x8
  #define _RC1REG_RC1REG_MASK                                 0xFF
  // alias bitfield definitions
  typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RCREGbits_t;
  
  extern volatile RCREGbits_t RCREGbits __at(0x119);
  // bitfield macros
  #define _RCREG_RC1REG_POSN                                  0x0
  #define _RCREG_RC1REG_POSITION                              0x0
  #define _RCREG_RC1REG_SIZE                                  0x8
  #define _RCREG_RC1REG_LENGTH                                0x8
  #define _RCREG_RC1REG_MASK                                  0xFF
  typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RCREG1bits_t;
  </code></pre>
  
  <p>I am trying to extract the typedef declarations in this file but <strong>only</strong> the typedef.</p>
  
  <p>I thought I had it it with <code>typedef\s+union\s+\{(\n.+)+bits_t;</code> and unfortunately, it's not quite right. In the sample provided above, all the text will be highlighted which is undesired. However,if there is a newline before the extern, it works. But I can't guarantee that there will be a newline there always.</p>
  
  <p>The desired output would be similar to</p>
  
  <pre><code>typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RC1REGbits_t;
  
  typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RCREGbits_t;    
  
  typedef union {
      struct {
          unsigned RC1REG                 :8;
      };
  } RCREG1bits_t;
  </code></pre>
  
  <p>How can bound my search to typedef union .... bits_t; ?</p>
  
  <p>Bonus points if its in python syntax (using the re package) since that's the language I am writing this in.</p>