Finding blank lines in a text file

Q

How to find blank lines in a text file using regular expression?

✍: Guest

A

You can use the following logic to find blank lines in a text file:

1. Read each line from the text file in a loop.

2. Validate each line with this regular expression:

^\s*$

3. If matched, you know that this line is a blank line.

Click the button to test this regular expression here online:

2013-01-29, 0👍, 0💬