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

erase — Remove substring occurrences from text inputs in MATLAB and RunMat.

erase(text, pattern) removes every occurrence of pattern from text. Supported text/pattern forms and expansion behavior match MATLAB semantics.

Syntax

newStr = erase(str, pattern)

Inputs

NameTypeRequiredDefaultDescription
strAnyYes—Input text (string/char/cell).
patternAnyYes—Pattern text list (scalar or array/cell).

Returns

NameTypeDescription
newStrAnyText with substring occurrences removed, preserving input container kind.

Errors

IdentifierWhenMessage
RunMat:erase:InvalidInputFirst argument is not a string array, char array, or cell array of text scalars.erase: first argument must be a string array, character array, or cell array of character vectors
RunMat:erase:PatternTypeSecond argument is not a text scalar/array/cell of text scalars.erase: second argument must be a string array, character array, or cell array of character vectors
RunMat:erase:CellElementCell arrays contain non-text elements or non-row char arrays.erase: cell array elements must be string scalars or character vectors
RunMat:erase:InternalErrorInternal output container construction failed.erase: internal error

How erase works

  • String inputs stay as strings. Missing string scalars (<missing>) propagate unchanged.
  • String arrays preserve their size and orientation. Each element has every supplied pattern removed.
  • Character arrays are processed row by row. Rows shrink as characters are removed and are padded with spaces so the result remains a rectangular char array.
  • Cell arrays must contain string scalars or character vectors. The result is a cell array with the same shape whose elements reflect the removed substrings.
  • The pattern input can be a string scalar, string array, character array, or cell array of character vectors/string scalars. Provide either a scalar pattern or a list; an empty list leaves text unchanged.
  • String, character, and cell matches are treated literally. RunMat pattern objects use their compiled pattern expression, matching the documented pattern-object form.
  • Both arguments are text or pattern values. Numeric values, including every typed-integer class and nested resident numeric values, are rejected before any provider access.

Does RunMat run erase on the GPU?

erase executes on host text containers. Resident numeric arguments, including values nested in cells, are rejected without downloading; providers do not implement a text kernel for this builtin.

GPU memory and residency

No. erase accepts host text and pattern values only. GPU-resident numeric values are not text and are rejected before provider access.

Examples

Remove a single word from a string scalar

txt = "RunMat accelerates MATLAB code";
clean = erase(txt, "accelerates ")

Expected output:

clean = "RunMat MATLAB code"

Remove multiple substrings from each element of a string array

labels = ["GPU pipeline"; "CPU pipeline"];
result = erase(labels, ["GPU ", "CPU "])

Expected output:

result = 2×1 string
    "pipeline"
    "pipeline"

Erase characters from a character array while preserving padding

chars = char("workspace", "snapshots");
trimmed = erase(chars, "s")

Expected output:

trimmed =

  2×8 char array

    'workpace'
    'naphot '

Remove substrings from a cell array of text

C = {'Kernel Planner', "GPU Fusion"};
out = erase(C, ["Kernel ", "GPU "])

Expected output:

out = 1×2 cell array
    {'Planner'}    {"Fusion"}

Provide an empty pattern list to leave the text unchanged

data = ["alpha", "beta"];
unchanged = erase(data, string.empty)

Expected output:

unchanged = 1×2 string
    "alpha"    "beta"

Remove delimiters before splitting text

path = "runmat/bin:runmat/lib";
clean = erase(path, ":")
parts = split(clean, "runmat/")

Expected output:

clean = "runmat/binrunmat/lib"
parts = 1×3 string
    ""    "bin"    "lib"

Using erase with coding agents

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

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

FAQ

Can I remove multiple patterns at once?⌄

Yes. Supply pattern as a string array or cell array. Each pattern is removed in order from every element of the input text.

What happens if pattern is empty?⌄

An empty pattern list leaves the input unchanged. Empty string patterns are ignored because removing empty text would have no effect.

Does erase modify the original data?⌄

No. It returns a new value with substrings removed. The input variables remain unchanged.

How are missing string scalars handled?⌄

They propagate unchanged. Calling erase on <missing> returns <missing>, matching MATLAB.

Can erase operate on GPU-resident data?⌄

Indirectly. RunMat automatically gathers GPU values to the host, performs the removal, and returns a host result. No explicit gpuArray calls are required.

How do I remove substrings using patterns or regular expressions?⌄

Use replace for literal substitution or regexprep for regular expressions when you need pattern-based removal rather than literal substring erasure.

Related Strings functions

Transform

append · deblank · eraseBetween · 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 erase is executed, line by line, in Rust.

  • View the source for erase 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 erase works
  • Does RunMat run erase on the GPU?
  • GPU memory and residency
  • Examples
  • Remove a single word from a string scalar
  • Remove multiple substrings from each element of a string array
  • Erase characters from a character array while preserving padding
  • Remove substrings from a cell array of text
  • Provide an empty pattern list to leave the text unchanged
  • Remove delimiters before splitting text
  • Using erase with coding agents
  • FAQ
  • Related Strings functions
  • Transform
  • Text Analytics
  • Core
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat