$reptok » History » Version 4
Per Amundsen, 02/23/2023 07:23 PM
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | 3 | Per Amundsen | *$reptok(text,token,new,[N],C)* |
| 4 | 1 | Per Amundsen | |
| 5 | Replaces the Nth matching token in text with a new token. |
||
| 6 | |||
| 7 | _[[$reptok]] is case-insensitive, see [[$reptokcs]] for case-sensitive version._ |
||
| 8 | |||
| 9 | *Parameters* |
||
| 10 | |||
| 11 | 4 | Per Amundsen | table(ktable). |
| 12 | |*Parameter*|*Description*| |
||
| 13 | | text | The text to tokenize. | |
||
| 14 | | token | Token to match. | |
||
| 15 | | new | New token to replace with. | |
||
| 16 | | [N] | If N = 0, all matching tokens, otherwise the Nth match. (Optional, default is 1) | |
||
| 17 | | C | The "ASCII":http://www.asciitable.com/ value to tokenize by. | |
||
| 18 | 1 | Per Amundsen | |
| 19 | *Example* |
||
| 20 | |||
| 21 | <pre> |
||
| 22 | ; Replace the first token matching 'b' with 'e' |
||
| 23 | //echo -ag $reptok(a.b.c.d,b,e,1,46) |
||
| 24 | |||
| 25 | ; Replace all tokens matching 'b' with 'e' |
||
| 26 | 2 | Per Amundsen | //echo -ag $reptok(b.b.b.c,b,e,0,46) |
| 27 | 1 | Per Amundsen | </pre> |