Forum Discussion
MiLK_MaN
Jun 13, 2012Nimbostratus
Why not just use split and then extract the field via lindex?
% set testuri "/mapper/time_map/datatype/comtype/37.777125/-122.419644/13/1309/3164.json?v=1°ree_buffer=0.002&callback=jQuery1720814429080274308_1339544764657&_=1339544771741"
/mapper/time_map/datatype/comtype/37.777125/-122.419644/13/1309/3164.json?v=1°ree_buffer=0.002&callback=jQuery1720814429080274308_1339544764657&_=1339544771741
% set split [split $testuri /]
{} mapper time_map datatype comtype 37.777125 -122.419644 13 1309 3164.json?v=1°ree_buffer=0.002&callback=jQuery1720814429080274308_1339544764657&_=1339544771741
% puts "[lrange $split 4 6]"
comtype 37.777125 -122.419644
% puts "[lindex $split 4]"
comtype
The scan statement will still work, but it seem it has troubles with the / being the first character, so this will work:
% scan $testuri {/%*[^/]/%*[^/]/%*[^/]/%[^/]/%[^/]/%[^/]} one two three
3
% puts $one
comtype
% puts $two
37.777125
% puts $three
-122.419644