stringlib::remove
-- Delete
substringsWith stringlib::remove
a substring can be deleted from
another string.
stringlib::remove(string1, string2 <,
option>)
string1, string2 |
- | non empty string |
First |
- | determines that only the first appearance of
string2 in string1 will be deleted |
the given string without the deleted parts
delete
, stringlib::subs
, stringlib::subsop
string2
has been found, the search for further
occurrences of it continues after its last letter; hence only the first
of several overlapping occurrences is detected. See Example 3.By default, out of several occurrences of the given substring all are removed.
>> stringlib::remove("abcdeabcdeabcde", "bc")
"adeadeade"
Using the option First
causes
stringlib::remove
to remove only the first occurrence of
the given substring.
>> stringlib::remove("abcdeabcdeabcde", "bc", First)
"adeabcdeabcde"
In the following example, the given substring occurs twice, where both instances of it do overlap. Only the first occurrence is removed.
>> stringlib::remove("aaa", "aa")
"a"
string::delete