Search code examples
notepad++editorediultraeditedifact

Repeated keywords to use to format/ convert structure EDI/BAYPLIE files


Is it possible or allowed to format the EDIFACT / BAYPLIE file when there are same repeated keywords eg ? *(RFF + BM: 1'EQD + CN +) opening that in editors (Notepad++ or UltraEdit) and convert /format structure each separate new lines?

Sample from editor extract for 3 containers as below:

RFF + BM: 1'EQD + CN +GESU6445322 45G0 + ++ 0 + + 5'NAD CA + EMC: 172: 147 20'LOC + + 0,781,584 + 5'MEA :: WT ++ KGM: 13400'LOC + 9 + + 11 + CNNBO'LOC DEHBG 'RFF + BM: 1'EQD + CN +ZCSU8245400 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,586 + 5'MEA :: WT ++ KGM: 12300'LOC + 9 + + 11 + CNNBO'LOC DEHBG 'RFF + BM: 1'EQD + CN +TCNU8547134 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,588 + 5'MEA :: WT ++ KGM: 07900'LOC + 9 + + 11 + CNNBO'LOC DEHBG 'RFF + BM: 1'EQD + CN + ...

In final result after converting the lines can be displayed in more easier visual way and start

RFF + BM: 1'EQD + CN +GESU6445322 45G0 + ++ 0 + + 5'NAD CA + EMC: 172: 147 20'LOC + + 0,781,584 + 5'MEA :: WT ++ KGM: 13400'LOC + 9 + + 11 + CNNBO'LOC DEHBG ' RFF + BM: 1'EQD + CN +ZCSU8245400 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,586 + 5'MEA :: WT ++ KGM: 12300'LOC + 9 + + 11 + CNNBO'LOC DEHBG ' RFF + BM: 1'EQD + CN +TCNU8547134 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,588 + 5'MEA :: WT ++ KGM: 07900'LOC + 9 + + 11 + CNNBO'LOC DEHBG 'RFF + BM: 1'EQD + CN +

How to make in Notepad++ or Ultraedit editors?


Solution

    • Ctrl+H
    • Find what: (?<=.)\bRFF \+ BM: 1'EQD \+ CN \+
    • Replace with: \n$0
    • check Match case
    • check Wrap around
    • check Regular expression
    • DO NOT CHECK . matches newline
    • Replace all

    Explanation:

    (?<=.)                     : Look behind, make sure we ahave a character before
    \b                         : word boundary, to not match xxxRFM
    RFF \+ BM: 1'EQD \+ CN \+  : literally (+ have to be escaped as it is a special character)
    

    Replacement:

    \n                  : linebreak, you could use "\r\n"
    $0                  : content of group 0 (ie the whole match)
    

    Result for given example:

    RFF + BM: 1'EQD + CN +GESU6445322 45G0 + ++ 0 + + 5'NAD CA + EMC: 172: 147 20'LOC + + 0,781,584 + 5'MEA :: WT ++ KGM: 13400'LOC + 9 + + 11 + CNNBO'LOC DEHBG '
    RFF + BM: 1'EQD + CN +ZCSU8245400 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,586 + 5'MEA :: WT ++ KGM: 12300'LOC + 9 + + 11 + CNNBO'LOC DEHBG '
    RFF + BM: 1'EQD + CN +TCNU8547134 45G0 + ++ 0 + + CA + 5'NAD ZIM 172: 147 20'LOC + + 0,781,588 + 5'MEA :: WT ++ KGM: 07900'LOC + 9 + + 11 + CNNBO'LOC DEHBG '
    RFF + BM: 1'EQD + CN + ...