Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove empty lines using Regex and AltSearch

I'm trying to match any white-space or blank lines in this test file, using AltSearch extension. For some reason, I can't match space between bar bar and line 4.

Here is test file. To post it to Stack Overflow, I changed spaces to periods and tabs to TABs. (When you will change it back for personal testing, note, there is TABTABTAB below line 3, it's easy to overlook).

line1

line2
..............TAB

line3
TABTABTAB

foo foo
bar bar



line4


TAB..............

line5

.................

line6

And here is 2 versions of my regex. Both works identically for me.

\p*^\s*\t*\p+
\p*^(\s||\t)*\p+

I know, batch script inside AltSearch will be more easy way (and I already have working batch). My interest is about don't using batch.

Also doesn't work. I don't understand, maybe this AltSearch is just buggy as hell?

(\p*^\s*\p+)||(\p*^\p*)
like image 465
john c. j. Avatar asked Nov 08 '22 19:11

john c. j.


1 Answers

Use the below regex

^$

Make sure you check the "Regular expressions" checkbox after expanding "Other Options" section.

Screenshot

Here is the screenshot from the Help in LibreOffice

Help

Ideally, ^\s*$ should work as I commented, it's strange it's not working in LO.

like image 67
Tushar Avatar answered Nov 14 '22 23:11

Tushar