$insert » History » Version 2
Paul Janson, 03/25/2021 11:05 PM
1 | 1 | Per Amundsen | _Added in 1.8.10_ |
---|---|---|---|
2 | |||
3 | *$insert(text, token, N)* |
||
4 | |||
5 | 2 | Paul Janson | Insert token into text after position N. |
6 | 1 | Per Amundsen | |
7 | *Parameters* |
||
8 | |||
9 | text - Text to insert to. |
||
10 | token - Token to insert. |
||
11 | 2 | Paul Janson | N - Position in text to insert the token after. |
12 | 1 | Per Amundsen | |
13 | 2 | Paul Janson | Resulting string has N characters of 'text', followed by 'token', followed by the remainder of 'text' |
14 | |||
15 | 1 | Per Amundsen | *Example* |
16 | |||
17 | <pre> |
||
18 | ; Insert 'wo' at position 6. |
||
19 | //echo -ag $insert(hello rld, wo, 6) |
||
20 | 2 | Paul Janson | //var %string hello rld , %pos 6 , %new wo | echo -ag $insert(%string, %new , %pos) same as $left(%string,%pos) $+ %new $+ $mid(%string,$calc(1+%pos)) |
21 | 1 | Per Amundsen | </pre> |