regex (or any other method) for finding the number of newline charcters in the text the user inputs in a textarea
i need to count the number of newline characters (or whatever is inserted when the user press the return key) in the value of a textarea. I think i should use a regular expression, but i'm really bad ad it and i don't know what i should look for.
<text开发者_如何学Carea id='countIt'></textarea>
var value = $('#countIt').val();
//need help from here
Of course if there is a smarter method, feel free to suggest
Try value.split(/\n/).length - 1
var breaksArray = value.match(/(\r\n|\n|\r)/);
精彩评论