## `stringlib::subsop` -- Substitution in a string

#### Introduction

`stringlib::subsop` removes one or more characters at a given position and inserts another substring at that position instead.

#### Call(s)

`stringlib::subsop(string, index = replacement)`

#### Parameters

`string` | - | non empty string
`index` | - | integer or range of integers that determines the chars to be replaced
`replacement` | - | any string to replace the given char or range

#### Returns

the given string with the replacement

#### Related Functions

`subsop`, `stringlib::pos`, `stringlib::remove`, `stringlib::subs`

#### Details

- The char with index `index` in `string` (if `index` is an integer) or the range of chars (if `index` is a range of integers) is removed. Instead `replacement` is inserted at that position. The inserted string need not have the same length.

#### Example 1

Delete the first character:

    >> stringlib::subsop("abcdeabcdeabcde", 0 = "")

                                 "bcdeabcdeabcde"

The 2nd to 3rd character will be replaced by `"xxx"`:

    >> stringlib::subsop("abcdeabcdeabcde", 1..2 = "xxx")

                                "axxxdeabcdeabcde"

Delete the characters 2 to 11:

    >> stringlib::subsop("abcdeabcdeabcde", 1..10 = "")

                                      "abcde"

#### Changes

- used to be called `string::subsop`

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000