title: Regex expression for excluding the letters inside [ ] (square brackets)
body: <p>I am trying to find the VALUE out of a KEY PAIR VALUE using a regular expression. VALUE can have [ ] (square bracket). If [ ] (square bracket) is present in the VALUE then I want to extract only the characters present outside [ ]. </p>
  
  <p>So target string could be as follows:</p>
  
  <pre><code>   key="val"  or  key="[val_notRequired1]val"  or  key="[val_notRequired1][val_notRequired2]val"
  </code></pre>
  
  <p>pattern that I initially used:</p>
  
  <pre><code>key=("[^"]*"|'[^']*')
  </code></pre>
  
  <p>which extracts all the characters inside <code>" "</code>. So I tried by adding a non-capturing group <code>(?:[\[][^*][\]])</code> to my pattern to escape the special characters <code>[</code> <code>]</code>. But the result is still the same. Am I close ??</p>
  
  <p>How can I extract only <code>val</code> in all the cases??
  I am using regex in javascript.</p>
  
  <p>Thanks.</p>