Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Tcl Library › splitting field
i am trying to split a field V99999-1-1234567891. What i want is the V99999-1. but splitting on the ” – ” using a 0 i get V99999, using a 1 i get 1 and using a 2 i get 1234567891. How do just keep the V99999-1 part?
Thanks for any ideas.
try this, assume “field” has the data and “result” will contain the stuff you want to keep;
set result [join [lrange [split $field -] 0 1] -]
Rob Abbott Cloverleaf Emeritus
This might work, too.
set value “”
regexp ^(.*?-.) $value match newValue
puts $newValue
Or something along those lines depending on exactly what you want to capture.
Also, maybe something as simple as string range may give you what you need?
-- Max Drown (Infor)
Many roads… Another one that works:
set result [string range $field 0 [expr [string last “-” $a]-1]]
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands
all work. Thanks a bunch gentleman.