title: Regex parse text with multiple recurring optional blocks
body: <p>I have a configuration output that I want to parse using regex. I want to capture every proxy-set definition including its proxy-ip config which is optional.</p>
  <p>I have succeeded to have 2 matched groups with 1 proxy-ip but the second proxy-ip isn't captured. Also it doesn't capture a proxy-set without proxy-ip set.</p>
  <p>I tried the following regex in regex101: <code>((proxy-set.*?((proxy-ip.*?)exit).*?)) /gms</code></p>
  <pre><code>       proxy-set 2
      proxy-name &quot;Teams&quot;
      proxy-enable-keep-alive using-options
      proxy-load-balancing-method random-weights
      is-proxy-hot-swap enable
      tls-context-name &quot;Teams&quot;
      sbcipv4-sip-int-name &quot;Teams&quot;
      activate
      proxy-ip 0
       proxy-address &quot;sip.pstnhub.microsoft.com:5061&quot;
       transport-type tls
       priority 1
       weight 1
       activate
      exit
      proxy-ip 1
       proxy-address &quot;sip.pstnhub.microsoft.com:5061&quot;
       transport-type tls
       priority 1
       weight 1
       activate
      exit
     exit
     proxy-set 2
      proxy-name &quot;Teams&quot;
      proxy-enable-keep-alive using-options
      proxy-load-balancing-method random-weights
      is-proxy-hot-swap enable
      tls-context-name &quot;Teams&quot;
      sbcipv4-sip-int-name &quot;Teams&quot;
      activate
      proxy-ip 0
       proxy-address &quot;sip.pstnhub.microsoft.com:5061&quot;
       transport-type tls
       priority 1
       weight 1
       activate
      exit
      proxy-ip 1
       proxy-address &quot;sip.pstnhub.microsoft.com:5061&quot;
       transport-type tls
       priority 1
       weight 1
       activate
      exit
     exit
     proxy-set 3
      proxy-name &quot;Teams&quot;
      proxy-enable-keep-alive using-options
      proxy-load-balancing-method random-weights
      is-proxy-hot-swap enable
      tls-context-name &quot;Teams&quot;
      sbcipv4-sip-int-name &quot;Teams&quot;
      activate
     exit
  </code></pre>