Popular recipes by Kiko The King http://code.activestate.com/recipes/users/772309/2003-11-20T07:58:29-08:00ActiveState Code RecipesGettok (Tcl)
2003-11-20T07:58:29-08:00Kiko The Kinghttp://code.activestate.com/recipes/users/772309/http://code.activestate.com/recipes/252145-gettok/
<p style="color: grey">
Tcl
recipe 252145
by <a href="/recipes/users/772309/">Kiko The King</a>
(<a href="/recipes/tags/datastructures/">datastructures</a>).
Revision 3.
</p>
<p>It returns the Xth token in a sentence..
like: i have a sentence divided by : and i want to get the second value
sentence:
set x "Value 1 : Value 2 : Value 3"
[gettok $x 2 :]
is returns <b>Value 2</b>
if you use 0 as the number...it will returns the number of tokens
in this case... <b>3</b></p>