title: Regex to extract multiline hash comments
body: <p>Currently suffering from writers block trying to come up with an elegant solution to this problem.</p>
  
  <p>Take the following example:</p>
  
  <pre><code>{
    "data": {
      # Some information about field 1
      # on multiple lines
      "field1": "XXXXXXXXXX",
  
      # Some more info on a single line
      "field2": "XXXXXXXXXXX",
  
      "field3": "#this would be ignored"
    }
  }
  </code></pre>
  
  <p>From the above, I'd like to extract the code comments together as a group, rather than individually. This grouping would happen if a line was commented right after another line. Comments will always start with whitespace followed by a #.</p>
  
  <p>Example result:</p>
  
  <pre><code>Capture group 1: Some information about field 1\n on multiple lines
  Capture group 2: Some more info on a single line
  </code></pre>
  
  <p>I could step over the lines and evaluate in code, but it would be nice to use a regex if possible. If you feel like a regex is not the correct solution for this problem, please explain your reasons why.</p>
  
  <p>SUMMARY:</p>
  
  <p>Thank you to everyone for submitting various solutions to this problem, this is a prime example of just how helpful the SO community can be. I will be spending an hour of my own time answering other tickets to make up for the collective time spent on this.</p>
  
  <p>Hopefully this thread will help others in future too.</p>