Replace space with commas but for first 28 characters per line
- 
 Each day I get a text file with 2,000+ lines like this - 406D69 NPT04S G-JMCH B734 West Atlantic UK -------- 25025 24450 1250 1250 30/01/2023 23:54:46 30/01/2023 23:59:31 I wish to have the output changed to - 
 406D69,NPT04S,G-JMCH,B734,West Atlantic UK -------- 25025 24450 1250 1250 30/01/2023 23:54:46 30/01/2023 23:59:31Ideally I want the output to be - 406D69,NPT04S,G-JMCH,B734,West Atlantic UK I would have suggested that anything including “--------” and after is removed but sometimes I get lines like this - 45CE4E -------- OY-SRN B762 Maersk Air Cargo -------- 17600 22950 0000 0000 30/01/2023 03:35:36 30/01/2023 19:58:48 but getting the commas only into the first 28 columns would be a awesome start, can notepad++ do this? 
- 
 This post is deleted!
- 
 At first I want to hint you that this forum provides the ability to post data in a way that the forum software doesn’t change/reformat your input data: - Surround your data with grave characters or
- click the codebutton in the toolbar above the text input area where you type your comments
  and replace the pre-selected text showing up with your data. Using method 1. your posting would be then: @David-Cummings said in Replace space with commas but for first 28 characters per line: Each day I get a text file with 2,000+ lines like this - 
 406D69 NPT04S G-JMCH B734 West Atlantic UK -------- 25025 24450 1250 1250 30/01/2023 23:54:46 30/01/2023 23:59:31
 I wish to have the output changed to -
 406D69,NPT04S,G-JMCH,B734,West Atlantic UK -------- 25025 24450 1250 1250 30/01/2023 23:54:46 30/01/2023 23:59:31
 Ideally I want the output to be -
 406D69,NPT04S,G-JMCH,B734,West Atlantic UK
 I would have suggested that anything including--------and after is removed but sometimes I get lines like this -
 45CE4E -------- OY-SRN B762 Maersk Air Cargo -------- 17600 22950 0000 0000 30/01/2023 03:35:36 30/01/2023 19:58:48
 but getting the commas only into the first 28 columns would be a awesome start, can notepad++ do this?
 To answer your question: Yes, Notepad++ can help you with your task. Provided that the line 45CE4E -------- OY-SRN B762 Maersk Air Cargo -------- 17600 22950 0000 0000 30/01/2023 03:35:36 30/01/2023 19:58:48should be converted to 45CE4E,--------,OY-SRN,B762,Maersk Air Cargotry the following: Open Search & Replace dialog and set the following options: - Find what: ^([^\h]+)\h+([^\h]+)\h+([^\h]+)\h+([^\h]+)\h+([\w ]+(?= -))(.+)$
- Replace with: $1,$2,$3,$4,$5
- Match whole word only: Unchecked
- Wrap around: Checked
- Search mode: Set option Regular expressionand uncheck. matches newline
 Finally click Replace allbutton.
- 
 Hello, @david-cummings, @alan-kilborn and All, Not difficult with regexes ! 
 So, let’s start with this INPUT text : 406D69 NPT04S G-JMCH B734 West Atlantic UK -------- 25025 24450 1250 1250 30/01/2023 23:54:46 30/01/2023 23:59:31- 
Open the Replace dialog ( Ctrl + H)
- 
SEARCH (?x-s) ^ (\S+) \x20 (\S+) \x20 (\S+) \x20 (\S+) \x20 (\S+) | \x20+ -------- .+
- 
REPLACE (?1\1,\2,\3,\4,\5)
- 
Untick all box options 
- 
Tick the Wrap aroundoption
- 
Select the Regular expressionserach mode
- 
Click on the Replace Allbutton
 => You should get your expected OUTPUT text : 406D69,NPT04S,G-JMCH,B734,West Atlantic UKIf OK, I’ll explain you how it works, next time ! Note that I use the Free Spacing mode (?x), in the search regex, in order to separate the main parts for a better comprehensionBest Regards, guy038 
- 



