Javascript Count Line Breaks
Join the DZone community and get the full member experience.
Join For FreeReturns the number of line breaks in a string.
function lineBreakCount(str){
/* counts \n */
try {
return((str.match(/[^\n]*\n[^\n]*/gi).length));
} catch(e) {
return 0;
}
}
JavaScript
Opinions expressed by DZone contributors are their own.
Comments