title: Regex to identify numbers except when enclosed by "[" "]"
body: <p>I want to write a regex such that I only match the first number NOT enclosed by square brackets.</p>
  
  <p>e.g. <code>asdadsas,*&amp;(*&amp;(*2asdasd*U(*&amp;*()&amp;(*3</code> should match 2 ( no square brackets )</p>
  
  <p>and <code>asdadsas,*&amp;(*&amp;(*[2]asdasd*U(*&amp;*()&amp;(*3</code> should match 3</p>
  
  <p>The regex I have so far is : <code>(?&lt;!\[)[0-9](?!\])</code></p>
  
  <p>However, the problem I have is that <code>[2</code> should still match 2.</p>
  
  <p>I only want to skip the number if it has a <code>[</code> to the left AND a <code>]</code> to the right.</p>
  
  <p>I don't know how ( or if its even possible) to implement this kind of conditional logic in a regex. </p>