$token » History » Version 2
Per Amundsen, 02/25/2017 04:05 PM
| 1 | 1 | Per Amundsen | _Added in 1.9.1_ |
|---|---|---|---|
| 2 | |||
| 3 | *$token(text,N,C)* |
||
| 4 | |||
| 5 | Returns the Nth token in text. |
||
| 6 | |||
| 7 | _Same as [[$gettok]]._ |
||
| 8 | |||
| 9 | 2 | Per Amundsen | _N-N2 can be used to get a range of tokens, both numbers can be negative._ |
| 10 | _N- can be used to get all tokens from position N._ |
||
| 11 | |||
| 12 | 1 | Per Amundsen | *Parameters* |
| 13 | |||
| 14 | text - The text to tokenize. |
||
| 15 | N - The Nth token to get. |
||
| 16 | C - The "ASCII":http://www.asciitable.com/ value to tokenize by. |
||
| 17 | |||
| 18 | *Example* |
||
| 19 | |||
| 20 | <pre> |
||
| 21 | ; Print the 3rd token in 'a.b.c.d.e' |
||
| 22 | //echo -ag $token(a.b.c.d.e,3,46) |
||
| 23 | 2 | Per Amundsen | |
| 24 | ; Print the second to forth token in 'a.b.c.d.e'. |
||
| 25 | //echo -ag $token(a.b.c.d.e,2-4,46) |
||
| 26 | |||
| 27 | ; Print all tokens from the second position. |
||
| 28 | //echo -ag $token(a.b.c.d.e,2-,46) |
||
| 29 | 1 | Per Amundsen | </pre> |