stringlib::remove -- Delete
substrings
IntroductionWith stringlib::remove a substring can be deleted from
another string.
Call(s)stringlib::remove(string1, string2 <,
option>)
Parametersstring1, string2 |
- | non empty string |
OptionsFirst |
- | determines that only the first appearance of
string2 in string1 will be deleted |
Returnsthe given string without the deleted parts
Related
Functionsdelete, stringlib::subs, stringlib::subsop
Detailsstring2 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.
Example
1By default, out of several occurrences of the given substring all are removed.
>> stringlib::remove("abcdeabcdeabcde", "bc")
"adeadeade"
Example
2Using the option First causes
stringlib::remove to remove only the first occurrence of
the given substring.
>> stringlib::remove("abcdeabcdeabcde", "bc", First)
"adeabcdeabcde"
Example
3In 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