Showing results for 
Search instead for 
Did you mean: 
Advocate I
Advocate I

Caret as beginning of line in REGEX - Identifying empty lines

I want to remove some empty lines in a file.

In REGEX the following always works to find an empty line








Since the caret indicates the beginning of a line, as documented by Microsoft here

But PAD totally ignores it. why? and what would be a good workaround?

Super User
Super User

Your regex is looking for line breaks at the beginning of a line. You can use trim for this:

Right, that is what I want to get rid of, lines that only contain line breaks.

The same REGEX formula is working in Dreamweaver and Notepad++, why is is not working in PAD?

Its not just for empty lines, for which trim might have been a good workaround, it does not work at all.

Super User
Super User

Might be a silly solution, but this technique removes empty lines:




Helper V
Helper V

At the risk of confusing the issue, here's another empty-line removal flow.





That said, I can see that in certain situations this might not work for you. This should match an empty line but process a carriage return if present:


where the '$' will (almost always?) be superfluous and you'd get the same result with


I'm trying to think of scenario where you'd have a carriage return and linefeed at the beginning of line, but also something else before the end of the line- stumped. If that's the case, would you mind posting an example of what you want to find with your regex?



Helpful resources

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Users online (2,473)