$puttok » History » Version 3
  Per Amundsen, 02/23/2023 07:13 PM 
  
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ | 
|---|---|---|---|
| 2 | |||
| 3 | *$puttok(text,token,N,C)* | ||
| 4 | |||
| 5 | Overwrites the Nth token in text with a new token. | ||
| 6 | |||
| 7 | 2 | Per Amundsen | _N-N2 can be used to get a range of tokens, both numbers can be negative._ | 
| 8 | _N- can be used to get all tokens from position N._ | ||
| 9 | |||
| 10 | 1 | Per Amundsen | *Parameters* | 
| 11 | |||
| 12 | 3 | Per Amundsen | table(ktable). | 
| 13 | |*Parameter*|*Description*| | ||
| 14 | | text | The text to tokenize. | | ||
| 15 | | token | Token to put. | | ||
| 16 | | N | The Nth token to replace. | | ||
| 17 | | C | The "ASCII":http://www.asciitable.com/ value to tokenize by. | | ||
| 18 | 1 | Per Amundsen | |
| 19 | *Example* | ||
| 20 | |||
| 21 | <pre> | ||
| 22 | 2 | Per Amundsen | ; Replace the second token with 'e'. | 
| 23 | 1 | Per Amundsen | //echo -ag $puttok(a.b.c.d,e,2,46) | 
| 24 | 2 | Per Amundsen | |
| 25 | ; Print the second to third token to 'e'. | ||
| 26 | //echo -ag $puttok(a.b.c.d,e,2-3,46) | ||
| 27 | |||
| 28 | ; Replace all tokens from position 2 to 'e'. | ||
| 29 | //echo -ag $puttok(a.b.c.d,e,2-,46) | ||
| 30 | 1 | Per Amundsen | </pre> |