title: Groovy replaceAll Comma
body: <p>I'm having issues with the replaceAll feature in Groovy.<br>
  I'm working on a CSV parser assignment, and I'm trying to replace commas with spaces.  I cannot figure out the syntax to actually replace them, as every time I run the script the data is returned with the commas still included.</p>
  
  <pre><code>class ActAsCSV {
      def headers = []
      def contents = []     
      def read() {
          def file = new File('C:/Users/Alex/Desktop/csv.txt')
          def lines = file.readLines()
          headers = lines[0].split(",")
  
          def last = lines.tail()
          def i = 0
          while (last[i] != null){last[i].replaceAll(/,(?=([^\"]*\"[^\"]*\")*[^\"]*$)/' ')
             println last[i]
             i++}
          }    
  }
  
  alex = new ActAsCSV()
  alex.read()
  </code></pre>
  
  <p>The CSV file looks like this:
      Year,Make,Model</p>
  
  <pre><code>1997,Ford,E350
  
  2000,Mercury,Cougar
  </code></pre>
  
  <p>The headers array works as it is supposed to.  The output after the current code is</p>
  
  <pre><code>1997,Ford,E350
  2000,Mercury,Cougar
  </code></pre>
  
  <p>I have tried </p>
  
  <p>","   </p>
  
  <p>',' </p>
  
  <p>/','/   </p>
  
  <p>/,/   </p>
  
  <p>and various regexp patterns I have found online. Literally nothing has worked.  I don't know what I am missing, I assumed replaceAll wouldn't be this hard.  I have looked over the documentation, but am unsure how to apply a string, closure combo.</p>