Replacing in VIM (assuming that the standard EDIFACT separators/escape characters for UNOA character set are in use):
:s/([^?] )(.)/1
2/g
Breaking down the regex:
([^?] )
- search for
which occurs after any character except ?
(the standard escape character) and capture these two characters as the first atom. These are the last two characters of each segment.
(.)
- Capture any single character following the segment terminator (ie. don t match if the segment terminator is already on the end of a line)
Then replace all matches on this line with a new line between the segment terminator and the beginning of the next segment.
Otherwise you could end up with this:
...
FTX+AAR+++FORWARDING?: Freight under Vendor?
s care.
NAD+BY+9312345123452
CTA+PD+0001:Terence Trent D?
Arby
...
instead of this:
...
FTX+AAR+++FORWARDING?: Freight under Vendor? s care .
NAD+BY+9312345123452
CTA+PD+0001:Terence Trent D? Arby
...