title: Replace windows carriage returns in Javascript
body: <p>I have a text file that I'm trying to parse into an array in Javascript.</p>
  
  <p>The fields are delimited by a double carat ('^^') and lines are terminated by a newline ('\n')</p>
  
  <p>One of the fields is a free flowing text description and the users often enter data by copying and pasting it from a PDF. This introduces rouge carriage returns into my stream ('\r\n').</p>
  
  <p>The stream looks like this:</p>
  
  <pre><code>Silver^^NM-GNF-000230^^Y^^18-JUN-13^^1800^^07-JUN-13^^L^^WF^^Matt Reidy^^2^^NM^^GNF^^Grant^^32.888889^^107.809722^^Vicinity of Kingston, NM^^24800^^ACRES^^5^^^^Highly varied fuels ranging from dry mixed conifer at the highest elevations to ponderosa pine, Pinyon-Juniper and interior chaparral dominate the lower elevations. Fuel loading is high due to lack of fire disturbance in past century.^^Extreme^^5590600 Ward Gulch^^CO-GWD-122^^Y^^18-JUN-13^^1730^^14-JUN-13^^L^^WF^^Jeff Berino^^3^^CO^^GWD^^Garfield^^39.689167^^107.734722^^10 miles North of Rifle, Colorado^^485^^ACRES^^95^^19-JUN-13^^Pinon juniper, sage, mixed conifer^^High^^1500000
  </code></pre>
  
  <p>There is a linefeed between 5590600 and Ward Gulch which determines the start of a new record.</p>
  
  <p>I have searched for a regex to replace the CR/LFs in my text and here's what I have:</p>
  
  <pre><code>var eplaceCarriageReturns = function(str) {
    var regxp = /[\r\n]/g
    str = str.replace(regxp, " ");
    return str;
  }
  </code></pre>
  
  <p>The problem is, this now eats my linefeeds too, turning my stream into one big block. If that's the only way, I'm drawing a blank on how to parse it as my newlines were the only thing to signify a new record.</p>
  
  <p>This problem has plagued me for years. I've solved it in Ruby by just removing all "CR/LF"s and then converting replacing remaining newlines with '^^'. This allows me to string.split('^^') and then chunk every 23 slices into a new array.</p>
  
  <p>Can't seem to figure it out in Javascript though.</p>