Count Blank Rows
-
Hi all,
Using Npp v7.9.5.
How do I count blank rows?
I tried Ctrl+F with Regex but I’m getting no result or incorrect result.
My RegEx pattern: ^\s*$What else can I do to get count of blank rows
Thanks
-w -
Maybe change your regular expression to
^\s*\R
?Here are my Count results for the
license.txt
file that ships with Notepad++: -
@dataprose said in Count Blank Rows:
Hi all,
Using Npp v7.9.5.
How do I count blank rows?
I tried Ctrl+F with Regex but I’m getting no result or incorrect result.
My RegEx pattern: ^\s*$The token
\s
means any whitespace, including newlines. With the asterisk, it means 0-or-more-as-many-as-possible. So that expression would matches consecutive newlines as a single match - so 100 blank lines in a row would count as one match.You either want it non-greedy using
^\s*?$
or you want to match only zero-or-more horizontal spaces on a line, with^\h*$
-
@alan-kilborn said in Count Blank Rows:
Maybe change your regular expression to ^\s*\R ?
Yea…my advice was bad. :-(
It will count several blank lines in a row as one.
Go with the Peter solution.