Hello, @ahamed-nawas-ali, @peterjones, @alan-kilborn and All,
@ahamed-nawas-ali, I’ll use a similar search regex to the @alan-kilborn’s one !
For example , given this INPUT text , below :
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 Learning
Selection
B. Home
Webinar
IDB
20214980
2021420214202216
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 Test
B. Home
Webinar
IDB
20214980
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 Try
Selection
B. Home
Webinar
IDB
20214980
2021420214202216
Blablah
OK
END of story
Open the Replace dialog ( Ctrl+H )
Uncheck all box options
Search (?-s)^(\d{4}-.+\t).+\R\K(?!\d{4}-|\R|\z)
Replace $1
If necessary, check the Wrap around option
Select the Regular expression search mode
Click, exclusively, on the Replace All button, several times, till the message Replace All: 0 occurrences were replaced... is displayed !
At the end, you should get this expected OUTPUT text :
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 Learning
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 Selection
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 B. Home
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 Webinar
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 IDB
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 20214980
2021-09-14T21:10:55+00:00 ATX Field3 Guy Field5 2021420214202216
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 Test
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 B. Home
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 Webinar
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 IDB
2021-09-15T11:19:14+00:00 BYQ Field3 Alan Field5 20214980
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 Try
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 Selection
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 B. Home
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 Webinar
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 IDB
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 20214980
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 2021420214202216
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 Blablah
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 OK
2021-09-16T15:07:46+00:00 ATX Field3 Peter Field5 END of story
Voila :-))
Notes :
As you can see, the number of columns, before the last one, is not a problem !
From beginning of line ( ^ ), the regex looks for a line beginning with 4 digits, followed with a dash character (\d{4}- ) and anything else till the last tabulation ( .+\t ) of current line
This search, so far, is memorized and stored as group 1
After the last field of the line and the line-break ( .+\R ), all the matched string is discarded ( \K )
Thus, the regex engine is now searching for a zero-length string, at beginning of the next line, but ONLY IF this next line does not begin with :
4 digits and a dash char
An other line-break
The very end of current file
When this assertion is true, it just inserts the group 1 contents at the very beginning of current line
Best Regards
guy038
P.S. :
If the condition to detect the header lines seems not restrictive enough, you may use this alternate search regex :
Search
(?-is)^(20\d\d-\d\d-\d\dT.+\t).+\R\K(?!20\d\d-\d\d-\d\dT|\R|\z)