Combining lines of text

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
wmhowell
Posts: 9
Joined: Thu Jan 17, 2008 7:03 pm

Combining lines of text

Post 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...
wmhowell
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
wmhowell
Posts: 9
Joined: Thu Jan 17, 2008 7:03 pm

Post by wmhowell »

Worked great. The hardest part was finding the Posix checkbox. Never used it before. Thanks again for your help.
wmhowell
Post Reply