Using a regular expression you can count the number of lines as
Alternately you can try split method as below.
var lines = $("#ptest").val().split("\n"); alert(lines.length);
working solution: http://jsfiddle.net/C8CaX/
More Related Contents:
- Is there a built in way to convert a comma-separated string to an array?
- How can I convert a comma-separated string to an array?
- How can I split a string into segments of n characters?
- Split a string based on multiple delimiters
- String split returns an array with more elements than expected (empty elements)
- Unicode string with diacritics split by chars
- Count the recurrence of a word
- How to get character array from a string?
- is the + operator less performant than StringBuffer.append()
- Get the string representation of a DOM node
- Get object property name as a string
- Does jQuery strip some html elements from a string when using .html()?