Remove numbers that aren't within square brackets in JS
<p>I have a generated a series of arrays in JavaScript but need to remove all numbers that are outside of square brackets.</p>

<p>Now I'm aware I need to use some form of Regex but I'm not sure how to use it in this instance.</p>

<p>Here's a sample of my arrays:</p>

<p>1[1,0.031410759078128],2[2,0.062790519529313],3[3,0.094108313318514],4[4,0.1253332335643],5[5,0.15643446504023]</p>

<p>etc.</p>

<p>How can I remove all the numbers that aren't in square brackets?</p>