# I am not big on *ASSUMING* sep characters
set elSep [string index $msg 105] ;# Normally ~
# get the header (ISA … ~) Just before TRN
set head [string range $msg 0 [string first “${elSep}TRN” $msg]]
# Remove header from message
set msg [string replace $msg 0 [string first “${elSep}TRN” $msg]]
Hope this helps