Remove CRLF Not Preceded by a Space
-
I have a text file that contains 10000 records exported from DataPerfect. There are many unwanted CRLFs that I need to remove. Most of the problem CRLFs are NOT preceded by a space. The valid CRLFs are usually preceded by a space.
Is there a way that I can use the replace function to remove the CRLFs that are NOT preceded by a space?
Any help is greatly appreciated. -
Any decent text editor has a way of doing what you need and Notepad++ is no exception.
Invoke the Replace dialog, and then:
Find-what zone:
(?<!\x20)\r\n
Replace-with zone: make sure this zone has nothing in it
Search-mode setting:Regular expression
Action: your choice of Replace or Replace AllSo in essence what the FInd-what formula is doing is finding a CRLF pair (the
\r\n
part), and then looking at the character immediately preceding. If it is NOT a space character (\x20
), then that particular CRLF pair gets replaced (with nothing as that is what is specified in Replace with), otherwise it is left as it is. -
Thanks Scott. Much appreciated.