Michael, I think your code won’t work if there is more than one rogue r inside a segment, am I correct?
Nasty problem. I totally agree that it should be fixed on the sending application, but we all know how it works in the real world.
I would try something like this:
* Replace all r with a high or low ascii value
regsub -all {rPID} $msg xff msg
regsub -all {rOBR} $msg xfe msg
etc…
* Remove all leftover r from the message
regsub -all r $msg “” msg
* replace the high/low ascii value with the proper r
regsub -all xff $msg {rPID} msg
regsub -all xfe $msg {rOBR} msg
etc…
You will need to know all segments that can be send though, which can be a long list.
Also be aware that the high/low ascii values may already be used by another proc.
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands