$gettok » History » Version 6
Per Amundsen, 02/23/2023 12:11 AM
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | *$gettok(text,N,C)* |
||
| 4 | |||
| 5 | Returns the Nth token in text. |
||
| 6 | |||
| 7 | 2 | Per Amundsen | _Same as [[$token]]._ |
| 8 | |||
| 9 | 5 | 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 | 6 | Per Amundsen | table(ktable). |
| 15 | |*Parameter*|*Description*| |
||
| 16 | | text | The text to tokenize. | |
||
| 17 | | N | The Nth token to get. | |
||
| 18 | | C | The "ASCII":http://www.asciitable.com/ value to tokenize by. | |
||
| 19 | 1 | Per Amundsen | |
| 20 | *Example* |
||
| 21 | |||
| 22 | <pre> |
||
| 23 | 5 | Per Amundsen | ; Print the 3rd token in 'a.b.c.d.e'. |
| 24 | 1 | Per Amundsen | //echo -ag $gettok(a.b.c.d.e,3,46) |
| 25 | 5 | Per Amundsen | |
| 26 | ; Print the second to forth token in 'a.b.c.d.e'. |
||
| 27 | //echo -ag $gettok(a.b.c.d.e,2-4,46) |
||
| 28 | |||
| 29 | ; Print all tokens from the second position. |
||
| 30 | //echo -ag $gettok(a.b.c.d.e,2-,46) |
||
| 31 | 1 | Per Amundsen | </pre> |