title: Push all numbers in square brackets into array
body: <p>I have tried/searched a lot but couldn't solve my problem. I guess it is quite easy and some one can give me a hint/link.</p>
  
  <p>I want to transfer all numbers in square brackets [123] on my webpage to a variable like this:  var all_sources_url = "123,123,123,123," and attach the variable to a link.</p>
  
  <p>Webpage example:</p>
  
  <pre><code>&lt;h1&gt;Text&lt;/h1&gt;
  &lt;p&gt;For a generative propagation, seeds must be harvested in winter from high quality sites in the nearby area or a site with similar growing conditions [682, 683].&lt;/p&gt;
  &lt;p&gt;Germination is increased by frost. Germination rates about 80 % can be achieved with good seeds [684].&lt;/p&gt;
  </code></pre>
  
  <p>Link example</p>
  
  <pre><code>&lt;h1&gt;Link&lt;/h1&gt;
  &lt;p&gt;&lt;a href="" target="_blank" id="all_sources"&gt;List of all cited literarure&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p>JS trial (if the variable would look like described above it would work, but constructing the variable does not work.)</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
    $(document).ready(function() {
     var all_sources_url;       
     $.each(($("p").html().match(/\[(.+?)\]/g)), function( index, value){
      all_sources_url += value;
     });
    $("#all_sources").attr("href", "quellen.php?id=" + all_sources_url + "&amp;name=literature");
   });
   &lt;/script&gt;
  </code></pre>
  
  <p>Thank you very much for your help!
  To</p>