title: Remove new line characters from data recieved from node event process.stdin.on("data")
body: <p>I've been looking for an answer to this, but whatever method I use it just doesn't seem to cut off the new line character at the end of my string.</p>
  
  <p>Here is my code, I've attempted to use <code>str.replace()</code> to get rid of the new line characters as it seems to be the standard answer for this problem:</p>
  
  <pre><code>process.stdin.on("data", function(data) {
      var str;
      str = data.toString();
      str.replace(/\r?\n|\r/g, " ");
      return console.log("user typed: " + str + str + str);
  });
  </code></pre>
  
  <p>I've repeated the <code>str</code> object three times in console output to test it. Here is my result:</p>
  
  <pre><code>hi
  user typed: hi
  hi
  hi
  </code></pre>
  
  <p>As you can see, there are still new line characters being read between each <code>str</code>. I've tried a few other parameters in <code>str.replace()</code> but nothing seems to work in getting rid of the new line characters.</p>