i'm using this function to count empty lines inside a string.
function count_empty_lines(text){
return text ? (text.match(/^[ \t]*$/gm) || []).length : 0;
}
I'm trying to edit that regex in order to implement a function that counts non empty lines.
function count_non_empty_lines(text){
}
Any ideas? Thanks!
text = [" a", "b", "", "c", "", "", " d "].join("\n")
cnt = (text.match(/^\s*\S/gm) || "").length
alert(cnt)
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