Page 1 of 1

'Replace All' finding '\t|$' finds line ending infinitely

Posted: Tue Dec 02, 2014 6:48 pm
by ionFreeman
I have some lines of tab delimited data, and I want pipe-delimited (and terminated) data. Since I have a leading tab, I search for '\t|$' and replace with '\|'. This creates and infinite loop -- it finds the line ending, replaces it with a '|' and finds the new line ending.

Replacing all \ts and $s separately works fine. But, 64-bit TextPad 7.4.0 can't handle the 'or' condition. Or something.

Posted: Wed Dec 31, 2014 9:40 pm
by kengrubb
Trying searching for (\t|$) rather than \t|$

If I am correct in understand that you have a leading tab you wish to retain, you could try this. This approach assumes there are no \xFF characters in your file.

RE Replace
Find: ^\t
Replace: \xFF

RE Replace
Find: \t
Replace: \|

RE Replace
Find: ([^\|])$
Replace: $1\|

RE Replace
Find: \xFF
Replace: \t

Posted: Thu Jan 01, 2015 7:58 pm
by ben_josephs
Does this do what you want?
Find what: (\t|$)(.|\n)
Replace with: |$2

[X] Regular expression

Replace All