04-12-2011

Javascript Count linebreaks

This function is quite quick and efficient in counting and returning the number of linebreaks in a string:

var countLinebreaks = function(str){
	return str.split(/\n|\f/).length;
}
 

Comments:

Your comment:

»

 

[x]