Page 1 of 1

Combining lines of text

Posted: Thu Jul 07, 2011 6:35 pm
by wmhowell
I have alot of records in a text file. Most are contained on one line but some records are split into two lines. If the 4th char is "1", "2", or "3" then the record is ok. If the 4th char is something else (usually but not always a "~") then the whole line should be added to the end of the previous line. This is real easy to do manually (just backspace at the beginning of the offending line) but not practical with a doc containing 750K lines of text.

Just want to know if there's a way to edit this file using regex. A Before and After sample is given below. Thanks for your help.


Before
|||1|||...
|||3|||...
|||3|||...
|||~~||...
|||2|||...
|||1|||...
AAAA...

After
|||1|||...
|||3|||...
|||3|||...|||~~||...
|||2|||...
|||1|||...AAAA...

Posted: Thu Jul 07, 2011 9:37 pm
by ben_josephs
Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: \n(...[^123])
Replace with: \1

[X] Regular expression

Replace All

Posted: Fri Jul 08, 2011 2:19 pm
by wmhowell
Worked great. The hardest part was finding the Posix checkbox. Never used it before. Thanks again for your help.