title: recursive matching for string delimiter with regular expression
body: <p>In verilog language, the statements are enclosed in a begin-end delimiter instead of bracket.  </p>
  
  <pre><code>always@ (*) begin
      if (condA) begin
         a = c
      end
      else begin
         b = d
      end
  end
  </code></pre>
  
  <p>I'd like to parse outermost begin-end with its statements to check coding rule in python. Using regular expression, I want results with regular expression like:</p>
  
  <pre><code>if (condA) begin
     a = c
  end
  else begin
     b = d
  end
  </code></pre>
  
  <p>I found similar answer for bracket delimiter.</p>
  
  <pre><code>int funcA() {
    if (condA) {
      b = a
    }
  } 
  </code></pre>
  
  <p>regular expression:</p>
  
  <pre><code>/({(?&gt;[^{}]+|(?R))*})/g
  </code></pre>
  
  <p>However, I don't know how to modify atomic group <strong>([^{}])</strong> for "begin-end"?</p>
  
  <pre><code>/(begin(?&gt;[??????]+|(?R))*end)/g
  </code></pre>