I have to get the value from a textarea using jQuery and count the number of newlines there. I'd like to do this using a regex-expression. Does anyone know how to do that?
regex does not have count. better use array like this
var val = textarea.value;
var arr = val.split(/[\n\r]/g);
var count = arr.length;
you could condense this in less rows and vars...
var count = $('textarea').val().split(/[\n\r]/g).length;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With