title: Javascript - Split dynamic string getting values inside brackets
body: <p>I have this as data input (it's dynamic so it can be 1 up to 5 brackets in the same string)</p>
  
  <pre><code>data["optionBase"] = {} //declaration
  data["optionBase"]["option"] = {} //declaration
  data["optionBase"]["option"][value] = {} //declaration
  data["optionBase"]["option"][value]["detail"] = somethingHere
  </code></pre>
  
  <p>Each line comes as a string, not as an array or any other type of javascript object.
  How can i get an array out of that string containing something like this:</p>
  
  <p>Line 1:</p>
  
  <pre><code>result[0] = "optionBase"
  </code></pre>
  
  <p>Line 2:</p>
  
  <pre><code>result[0] = "optionBase"
  result[1] = "option"
  </code></pre>
  
  <p>Line 3:</p>
  
  <pre><code>result[0] = "optionBase"
  result[1] = "option"
  result[2] = value
  </code></pre>
  
  <p>Line 4:</p>
  
  <pre><code>result[0] = "optionBase"
  result[1] = "option"
  result[2] = value
  result[3] = "detail"
  </code></pre>