Posted to tcl by mjanssen at Wed Oct 07 15:31:04 GMT 2020view pretty
proc parse {input} {
set prefix " $input"
set part {}
set result {}
set instring false
foreach prev [split $prefix {}] curr [split $input {}] {
if {$instring && $curr eq "\"" && $prev ne "\\"} {
lappend result $part
set instring false
continue
}
if {!$instring && $curr eq "\"" && $prev ne "\\"} {
set part {}
set instring true
continue
}
append part $curr
}
return $result
}