Javascript count line breaks
1 2 function lineBreakCount(str){ 3 /* counts \n */ 4 try { 5 return((str.match(/[^\n]*\n[^\n]*/gi).length)); 6 } catch(e) { 7 return 0; 8 } 9 }
DZone Snippets > featurelover > text
13375 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Jochen Preusche http://www.jochenpreusche.de
1 2 function lineBreakCount(str){ 3 /* counts \n */ 4 try { 5 return((str.match(/[^\n]*\n[^\n]*/gi).length)); 6 } catch(e) { 7 return 0; 8 } 9 }