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.
<textarea id='countIt'></textarea>
var value = $('#countIt').val();
//need help from here
Of course if there is a smarter method, feel free to suggest
尝试value.split(/\\n/).length - 1
var breaksArray = value.match(/(\r\n|\n|\r)/);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.