title: Replace <br /> in a textarea with a line separator ( Javascript )
body: <p>I guess this will be answered in two minutes but I am not able to google out a solution.</p>
  
  <p>Tried: <a href="https://stackoverflow.com/questions/8062399/how-replace-html-br-with-newline-character-n">this</a>, <a href="https://stackoverflow.com/questions/7672460/change-br-to-n-r-in-firefox-and-chrome">this</a></p>
  
  <p>I have a textarea which first recieves some data from the server (dynamically using AJAX). The text in the textarea may look like this:</p>
  
  <pre><code>Hello&amp;nbsp;Cruel&amp;nbsp;&lt;br&amp;nbsp;/&gt;World!
  </code></pre>
  
  <p>My users do not like the look of this :)</p>
  
  <p>So I wrote a very simple function:</p>
  
  <pre><code>    function replaceHtml( string_to_replace ) 
      {
          var result = replaceAll( string_to_replace, "&amp;nbsp;", " ");
          result = result.replace(/&lt;br\s*\/?&gt;/mg,"\n\r"); // or "\n", "\r", "\r\n"
          return result;
       }
  </code></pre>
  
  <p>My output looks like this:</p>
  
  <pre><code>Hello Cruel World!
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>Hello Cruel
  World!
  </code></pre>
  
  <p>I would love a solution that is at most 5 lines long and can be applied with all browsers and OSes</p>
  
  <p>Btw, Im no fan of regexes, so maybe the real problem will be there..</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/6833269/javascript-platform-independent-line-separator">From this answer</a> and mr Michael_B I got this solution, which is working for me, but I've got a hunch the character might not be the best solution there is:</p>
  
  <pre><code>function replaceHtml( string_to_replace ) 
  {
      return string_to_replace.replace(/&amp;nbsp;/g, ' ').replace(/&lt;br.*?&gt;/g, '\u2028');
  }
  </code></pre>