title: Using regex to replace all spaces NOT in quotes in Ruby
body: <p>I'm trying to write a regex to replace all spaces that are not included in quotes so something like this:</p>
  
  <pre><code>a = 4, b = 2, c = "space here"
  </code></pre>
  
  <p>would return this:</p>
  
  <pre><code>a=4,b=2,c="space here"
  </code></pre>
  
  <p>I spent some time searching this site and I found a similar q/a ( <a href="https://stackoverflow.com/questions/79968/split-a-string-by-spaces-in-python#80449">Split a string by spaces -- preserving quoted substrings -- in Python</a> ) that would replace all the spaces inside quotes with a token that could be re-substituted in after wiping all the other spaces...but I was hoping there was a cleaner way of doing it.</p>