Skip to content

eraseBetween

Remove the substring between two boundary patterns.

s = eraseBetween(str, startMark, endMark)
s = eraseBetween(str, startMark, endMark, 'Boundaries', bv)

Removes from str the substring lying between startMark and endMark. The 'Boundaries' option controls whether the markers themselves are kept ('exclusive', default) or removed ('inclusive').

eraseBetween('foo<bar>baz', '<', '>') % 'foo<>baz'
eraseBetween('foo<bar>baz', '<', '>', 'Boundaries', 'inclusive') % 'foobaz'
  • erase — Remove all occurrences of a pattern from a string.
  • strrep — Replace all occurrences of a substring.