title: RegEx: nested tags
body: <p>I use regexp, but I cant do it for my case. I have create own engine like DLE. 
  I have tags like [a],[/a],[b],[/b] etc. I use regexp like </p>
  
  <pre><code>'\\[a\\](.*?)\\[/a\\]'si 
  </code></pre>
  
  <p>or like</p>
  
  <pre><code>'\\[a\\](.*?)(\\[/a\\])+'si
  </code></pre>
  
  <p>and it don't work how I want.
  I need receive:</p>
  
  <pre><code>from '[a]delete[/a]' : ''
  
  from '[a][b]delete[/b][/a]' : '',
  
  from '[a][a]delete[/a][/a]' : '', with '\\[a\\](.*?)\\[/a\\]'si it returns '[/a]'
  
  from '[b][a]delete[/a][b]' : '[b][/b]'
  
  from '[b][a]delete[/a][b] [a]delete[/a]' : '[b][/b]'
  
  from '[a]
            delete
            [a]
                [b]delete[/b]
            [/a]
            delete
        [/a]
        [b]
            [a]delete[/a]
            nodelete
        [/b]'
        :
        '[b]
            nodelete
        [/b]'
  </code></pre>
  
  <p>Help me to create right regexp!</p>