title: How to count the number of lines of a string in javascript
body: <p>I want to count the number of lines in a string </p>
  
  <p>i tried to use this stackoverflow answer :</p>
  
  <pre><code>lines = str.split("\r\n|\r|\n"); 
  return  lines.length;
  </code></pre>
  
  <p>on this string(which was originally a buffer):</p>
  
  <pre><code> GET / HTTP/1.1
   Host: localhost:8888
   Connection: keep-alive
   Cache-Control: max-age=0
   User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML,like Gecko) Chrome/15.0.874.121 Safari/535.2
   Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
   Accept-Encoding: gzip,deflate,sdch
   Accept-Language: en-US,en;q=0.8
   Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  </code></pre>
  
  <p>and for some reason i got lines='1'.</p>
  
  <p>any idea how to make it work?</p>