set pat “OBR.*?OBR”
set OBRlist [regexp -all -inline — $pat $msg].
As I create the groups I will evaluate and create a goodgroup list which I will use to put the message back together. I have been to iterate through the segements (foreach segment $msgseglist {) and create the first group but cannot create any additional groups. For example:
OBR1 bad
NTE1
NTE1
ORC2
OBR2 good
NTE2
NTE2
ORC3 bad
OBR3
NTE3
I need to eliminate the bad segment and the other segments in its group and keep the good group and then put the message back together. Here is the code I have right now (its pretty crude):
foreach segment $msgseglist {
echo “segment = $segment”
if {([crange $segment 0 2] == “OBR”)} {
set pat “OBR.*?OBR”
set OBRlist [regexp -all -inline — $pat $msg]
echo “OBRlist=$OBRlist”
set OBRfieldlist [split $OBRlist |]
set codefld [lindex $OBRfieldlist 4]
set codelist [split $codefld ^]
set code [lindex $codelist 0]
echo “code = $code”
set 1stNum [string range $code 0 0]
echo “1stNum = $1stNum”
if {$1stNum == 7} {
set killgroup [lappend killgroup $OBRlist]
echo “killgroup = $killgroup”
} else {
set goodgroup [lappend goodgroup $OBRlist]
echo “goodgroup = $goodgroup”
}
set pat “OBR.*?OBR”
set OBRlist [regexp -all -inline — $pat $msg]
echo “OBRlist=$OBRlist”
set goodgroup [lappend goodgroup $OBRlist]
echo “goodgroup = $goodgroup”
}
set segcounter1 [incr segcounter1]
}
Any ideas how I can make this work?
Thank you