title: Regular expressions using conditions
body: <p>I know that I really need to read one of these books (<a href="https://rads.stackoverflow.com/amzn/click/com/1449319432" rel="nofollow noreferrer" rel="nofollow noreferrer">1</a>, <a href="https://rads.stackoverflow.com/amzn/click/com/0596528124" rel="nofollow noreferrer" rel="nofollow noreferrer">2</a>) to learn regular expressions but in the meantime I have a small question for the people that already have the knowledge.
  I want to write a snippet for sublime text which leaves the inner spaces for parentheses if I start typing but deletes everything inside the parentheses if I delete the selection. </p>
  
  <p>Triggered:</p>
  
  <pre><code>( ${1:anything could be typed here} )
  </code></pre>
  
  <p>Typed:</p>
  
  <pre><code>( I_wrote_that )
  </code></pre>
  
  <p>Deleted:</p>
  
  <pre><code>()
  </code></pre>
  
  <p>I do not ask for someone to write it for me, but a clear explanation on conditional regular expressions would be much appreciated.
  Thanks !</p>
  
  <p>NB: I am referring to the conditional syntax in regular expressions.
  NB2: Here is an example with a C/C++ printf.</p>
  
  <p>Snippet:</p>
  
  <pre><code>printf( "${1:%s}\\n" ${1/([^%]|%%)*(%.)?.*/(?2:,:\);)/} $2 ${1/([^%]|%%)*(%.)?.*/(?2:\);))/}
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>printf( "%s\n" ,  );
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>printf( "\n" );  
  </code></pre>