RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • append
    • deblank
    • erase
    • eraseBetween
    • erasePunctuation
    • eraseURLs
    • extractAfter
    • extractBefore
    • extractBetween
    • insertAfter
    • insertBefore
    • join
    • lower
    • pad
    • replace
    • replaceBetween
    • reverse
    • split
    • splitlines
    • strcat
    • strip
    • strjoin
    • strjust
    • strrep
    • strsplit
    • strtrim
    • upper

eraseBetween — Delete text between boundary markers in MATLAB and RunMat.

eraseBetween(text, start, stop) removes text between two boundary markers. String/position markers, expansion rules, and 'Boundaries' option behavior follow MATLAB semantics.

Syntax

newText = eraseBetween(str, start, end)
newText = eraseBetween(str, start, end, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
strAnyYes—Input text scalar/array/cell.
startAnyYes—Start boundary marker text or positive integer position(s).
endAnyYes—End boundary marker text or positive integer position(s).
NameStringScalarYes—Option name (`Boundaries`).
ValueAnyVariadic—Option value and additional Name/Value pairs.

Returns

NameTypeDescription
newTextAnyText with between-boundary content erased, preserving text container semantics.

Errors

IdentifierWhenMessage
RunMat:eraseBetween:InvalidInputFirst argument is not a string array, character array, or cell array of text scalars.eraseBetween: first argument must be a string array, character array, or cell array of character vectors
RunMat:eraseBetween:BoundaryTypeStart/end boundaries are mixed text/numeric domains or use unsupported boundary types.eraseBetween: start and end arguments must both be text or both be numeric positions
RunMat:eraseBetween:PositionTypeNumeric boundary positions are not positive finite integers.eraseBetween: position arguments must be positive integers
RunMat:eraseBetween:NameValuePairName/value options are not supplied in complete pairs.eraseBetween: name-value arguments must appear in pairs
RunMat:eraseBetween:OptionNameAn option name other than `Boundaries` was supplied.eraseBetween: unrecognized parameter name
RunMat:eraseBetween:OptionValue`Boundaries` option value is not `inclusive` or `exclusive`.eraseBetween: 'Boundaries' must be either 'inclusive' or 'exclusive'
RunMat:eraseBetween:CellElementCell text input/boundary contains non-text values or non-row char arrays.eraseBetween: cell array elements must be string scalars or character vectors
RunMat:eraseBetween:SizeMismatchText/boundary inputs are not broadcast-compatible for erase semantics.eraseBetween: boundary sizes must be compatible with the text input
RunMat:eraseBetween:InternalErrorInternal output construction failed.eraseBetween: internal error

How eraseBetween works

  • Accepts string scalars, string arrays, character arrays (row-by-row), and cell arrays containing string scalars or character vectors; the output keeps the same container type.
  • Boundary arguments can be literal text, scalar pattern objects, or numeric positions. Both boundaries in a call must use the same representation—mixing text/pattern and numeric markers raises a size/type error. Broader pattern-array containers depend on shared pattern-array runtime representation and are not claimed by this implementation.
  • Text boundaries are exclusive by default: the markers are preserved while the enclosed text is deleted. Numeric positions are inclusive by default: characters at startPos and endPos are deleted together with the interior.
  • 'Boundaries','inclusive' removes the markers themselves; 'Boundaries','exclusive' keeps them. The option is case-insensitive and must be supplied as name-value pairs.
  • Missing string scalars propagate (the MATLAB missing placeholder in either boundary or text yields <missing> in the result). When a boundary cannot be located, eraseBetween returns the original element unchanged.
  • Numeric positions are validated as positive integers and interpreted using MATLAB’s 1-based indexing rules. All eight typed-integer classes are read exactly as documented numeric structural controls.
  • MATLAB-compatible array forms require each boundary to be scalar or the same size as the text input. RunMat mode additionally permits general broadcast-compatible boundary shapes.
  • Row-wise character matrices, cells containing string scalars, and GPU-resident position arrays are separately gated RunMat extensions.

Does RunMat run eraseBetween on the GPU?

The builtin performs text work on the CPU. In RunMat mode, resident numeric position controls gather through their authoritative storage and outputs remain on host; strict compatibility gates that extension before download.

GPU memory and residency

No text output remains resident. GPU-resident numeric position controls are a RunMat extension and are gathered exactly in RunMat mode; strict compatibility rejects them before provider access.

Examples

Removing text between substrings

txt = "The quick brown fox";
result = eraseBetween(txt, "quick", " fox")

Expected output:

result = "The quick fox"

Deleting substrings across a string array

str = ["The quick brown fox jumps"; "over the lazy dog"];
starts = ["quick"; "the"];
ends = [" fox"; " dog"];
trimmed = eraseBetween(str, starts, ends)

Expected output:

trimmed = 2×1 string
    "The quick fox jumps"
    "over the dog"

Removing characters between numeric positions

name = "Edgar Allen Poe";
short = eraseBetween(name, 6, 11)

Expected output:

short = "Edgar Poe"

Using inclusive boundaries to drop the markers

sentence = "The quick brown fox jumps over the lazy dog";
collapsed = eraseBetween(sentence, " brown", "lazy", "Boundaries", "inclusive")

Expected output:

collapsed = "The quick dog"

Operating on character arrays while preserving padding

chars = char("Server<GPU>", "Engine<CPU>");
trimmed = eraseBetween(chars, "<", ">", "Boundaries", "inclusive")

Expected output:

trimmed =

  2×6 char array

    "Server"
    "Engine"

Preserving element types in cell arrays

C = {'alpha<1>', "beta<2>";
     'gamma<3>', "delta<4>"};
clean = eraseBetween(C, "<", ">", "Boundaries", "inclusive")

Expected output:

clean =
  2×2 cell array
    {'alpha'}    {"beta"}
    {'gamma'}    {"delta"}

Handling missing strings safely

texts = [missing, "Planner<GPU>"];
result = eraseBetween(texts, "<", ">")

Expected output:

result = 1×2 string
    "<missing>"    "Planner"

Using eraseBetween with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how eraseBetween changes the result.

Run a small eraseBetween example, explain the result, then change one input and compare the output.

FAQ

Which argument types does eraseBetween accept?⌄

The first argument can be a string scalar, string array, character array, or cell array of character vectors / string scalars. Boundary arguments must both be text markers or both be numeric positions.

What happens if a boundary is not found?⌄

The original text is returned unchanged. Missing string scalars also propagate unchanged.

How does 'Boundaries','inclusive' interact with text markers?⌄

Inclusive mode removes the matched start and end markers together with the enclosed text. Exclusive mode keeps the markers and removes only the interior.

Can I broadcast scalar boundaries across an array input?⌄

Scalar markers apply to every text element. Nonscalar boundary arrays must be the same size as the text input in MATLAB-compatible mode; RunMat mode separately enables general broadcast-compatible shapes.

Are GPU inputs supported?⌄

GPU values are gathered to host memory before processing. The builtin always returns host-resident outputs and is registered as an Accelerate sink, so fusion planning does not keep text on the GPU.

Does eraseBetween validate numeric positions?⌄

Yes. Positions are parsed exactly as positive integers using MATLAB’s 1-based indexing. The current public source does not fully specify every out-of-range case, so those details remain evidence-open rather than being presented as MATLAB guarantees.

Related Strings functions

Transform

append · deblank · erase · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper

Text Analytics

addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding

Core

blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native

Search

contains · endsWith · matches · startsWith · strfind

Pattern

digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern

Regex

regexp · regexpi · regexprep

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how eraseBetween is executed, line by line, in Rust.

  • View the source for eraseBetween in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How eraseBetween works
  • Does RunMat run eraseBetween on the GPU?
  • GPU memory and residency
  • Examples
  • Removing text between substrings
  • Deleting substrings across a string array
  • Removing characters between numeric positions
  • Using inclusive boundaries to drop the markers
  • Operating on character arrays while preserving padding
  • Preserving element types in cell arrays
  • Handling missing strings safely
  • Using eraseBetween with coding agents
  • FAQ
  • Related Strings functions
  • Transform
  • Text Analytics
  • Core
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat