title: Formatting a file using regex
body: <p>Spent some time trying to format a file with roughly 5,000 hex values, however with no luck. For example</p>
  
  <pre><code>1b 00 10 50 a3 bb 0e b7 ff ff 00 00 00 00 09 00
  01 02 00 01 00 85 03 0e 00 00 00 55 0e 04 66 03
  2a 38 32 80 00 0e 00 2f c2
  
  1b 00 10 50 a3 bb 0e b7 ff ff 00 00 00 00 09 00
  01 02 00 01 00 85 03 2b 00 00 00 55 2b 04 58 28
  2a 39 32 80 00 01 00 12 57 4d 32 34 30 20 41 43
  20 56 65 72 2e 41 00 00 23 06 00 0a 23 06 00 0a
  01 00 00 c0 14 56
  
  1b 00 30 a6 59 b8 0e b7 ff ff 00 00 00 00 09 00
  00 02 00 01 00 04 03 0d 00 00 00 55 0d 04 33 2a
  03 3a 32 40 00 0e be 40
  
  1b 00 f0 01 f1 b6 0e b7 ff ff 00 00 00 00 09 00
  00 02 00 01 00 04 03 0e 00 00 00 55 0e 04 66 2a
  00 3b 32 40 00 01 05 c9 b1
  
  and so on..
  </code></pre>
  
  <p>I need to format in the following matter:</p>
  
  <pre><code>1b 00 10 50 a3 bb 0e b7 ff ff 00 00 00 00 09 00 01 02 00 01 00 85 03 0e 00 00 00 55 0e 04 66 03 2a 38 32 80 00 0e 00 2f c2
  
  1b 00 10 50 a3 bb 0e b7 ff ff 00 00 00 00 09 00 01 02 00 01 00 85 03 2b 00 00 00 55 2b 04 58 28 2a 39 32 80 00 01 00 12 57 4d 32 34 30 20 41 43 20 56 65 72 2e 41 00 00 23 06 00 0a 23 06 00 0a 01 00 00 c0 14 56
  
  1b 00 30 a6 59 b8 0e b7 ff ff 00 00 00 00 09 00 00 02 00 01 00 04 03 0d 00 00 00 55 0d 04 33 2a 03 3a 32 40 00 0e be 40
  
  1b 00 f0 01 f1 b6 0e b7 ff ff 00 00 00 00 09 00 00 02 00 01 00 04 03 0e 00 00 00 55 0e 04 66 2a 00 3b 32 40 00 01 05 c9 b1
  </code></pre>
  
  <p>Basically put each hex block into one line still separated by space. For the life of me, i cannot figure out the regular expression to format this for me. I have tried different expressions but everything i tried either removes the line that separates hex blocks or grabs a last character of the line instead of the actual \n. </p>
  
  <p>Maybe there is a better way of formatting files other than using regex</p>