erase
Delete substrings within strings
Syntax
newStr = erase(str,match)
Description
newStr = erase(
deletes all occurrences ofstr
,match
)match
instr
. Theerase
function returns the rest of the string asnewStr
.
Ifmatch
is a string array or a cell array of character vectors, thenerase
deletes every occurrence of every element ofmatch
instr
. Thestr
andmatch
arguments do not need to be the same size.
Examples
Input Arguments
Tips
To delete multiple occurrences of a match when the occurrences overlap, use the
strrep
function.erase
only deletes the first occurrence when occurrences overlap.
Extended Capabilities
See Also
count
|eraseBetween
|extractAfter
|extractBefore
|extractBetween
|insertAfter
|insertBefore
|join
|pad
|replace
|replaceBetween
|size
|split
|strlength
|strsplit
Introduced in R2016b
Was this topic helpful?