How to count the number of lines with text in the input box?

similar to the function shown in the following figure, blank lines can be ignored, and the number of lines can be counted regardless of whether they are pasted or typed.


value.trim().split(/\r?\n\s*/).length

str.match(/^\s*\S/mg).length
Menu