Question

I'm in a sticky situation with a CSV file. I have many rows of text with CRLF throughout which is ruining the formatting when I put it in Excel. I need to be able to remove the CRLF only when not preceded by a tab delimiter.

I plan on doing this with a regular expression in find and replace (but open to other ideas) I've read that it is possible to have if statements in regex and wondered if it's possible to highlight for removal based upon the outcome of the if?

Was it helpful?

Solution

i think regular expression matching what you want is [^\t]\r\n

you can use a text editor that support regular expression to do the search and replace, in vim it can be something like

%s/\t\@!\r\n/<your_replacement>/g

note that \@! is the vim way of not, in other solutions this can be different

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top