RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
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 and pattern forms include string, character, cell text and pattern objects.

Syntax

newStr = erase(str, pattern)

Inputs

str
Type
Any
Required
Yes
Description
Input text (string/char/cell).
pattern
Type
Any
Required
Yes
Description
Pattern text list (scalar or array/cell).
NameTypeRequiredDefaultDescription
strAnyYes—Input text (string/char/cell).
patternAnyYes—Pattern text list (scalar or array/cell).

Returns

newStr
Type
Any
Description
Text with substring occurrences removed, preserving input container kind.
NameTypeDescription
newStrAnyText with substring occurrences removed, preserving input container kind.

Errors

RunMat:erase:InvalidInput
When
First argument is not a string array, char array, or cell array of text scalars.
Message
erase: first argument must be a string array, character array, or cell array of character vectors
RunMat:erase:PatternType
When
Second argument is not a text scalar/array/cell of text scalars.
Message
erase: second argument must be a string array, character array, or cell array of character vectors
RunMat:erase:CellElement
When
Cell arrays contain non-text elements or non-row char arrays.
Message
erase: cell array elements must be string scalars or character vectors
RunMat:erase:InternalError
When
Internal output container construction failed.
Message
erase: internal error
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

Behavior

String inputs stay strings and missing string scalars propagate unchanged. String arrays preserve size and orientation; each element has every supplied pattern removed.

In RunMat mode, multirow character arrays are processed row by row. Rows can shrink, then receive trailing spaces so the result is rectangular. Cell arrays retain their shape; cells containing string scalars are also a RunMat extension. MATLAB compatibility mode accepts character vectors and cell arrays of character vectors, but rejects these extended forms.

The pattern can be a string scalar or array, character array, cell array of text scalars, or a pattern object. Pattern lists are applied in order; an empty list leaves the input unchanged, and empty literal patterns have no effect. Text patterns are literal, while pattern objects use their compiled expression. The current pattern engine does not support every MATLAB expression construct, including lookaround and backreferences.

Numeric and logical values, including all typed-integer classes and nested resident numeric values, reject before provider access. The input variables are not modified.

Placement and effects

erase is a host text operation with no resident text representation, provider kernel or fusion route. GPU-resident numeric arguments are invalid text and reject before gathering.

The operation is pure apart from validation or pattern errors. It has no callback, workspace, filesystem, random, time or distributed execution effect.

Examples

Remove one word from a string

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

Expected output:

clean = "RunMat MATLAB code"

Remove several substrings from string arrays

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

Expected output:

result = ["pipeline"; "pipeline"]

Erase characters while retaining a rectangular char array

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

Expected output:

trimmed = ['workpace'; 'naphot  ']

Remove substrings from a mixed text cell

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

Expected output:

out = {'Planner', "Fusion"}

Keep text unchanged with an empty pattern list

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

Expected output:

unchanged = ["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 = [""; "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 a string or cell array of patterns. Each is removed in order from every input element.

What happens if pattern is empty?⌄

An empty pattern list leaves input unchanged. Empty literal patterns are ignored.

Does erase modify the original data?⌄

No. It returns a new value; the inputs remain unchanged.

How are missing strings handled?⌄

Missing string scalars propagate unchanged.

Can erase operate on GPU-resident data?⌄

No resident text representation or GPU kernel is available. GPU-resident numeric values are not text and reject before provider access; there is no implicit gather.

How do I remove text using regular expressions?⌄

Use regexprep for regular-expression replacement; erase accepts literal text patterns or RunMat pattern objects.

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

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Behavior
  • Placement and effects
  • Examples
  • Remove one word from a string
  • Remove several substrings from string arrays
  • Erase characters while retaining a rectangular char array
  • Remove substrings from a mixed text cell
  • Keep text unchanged with an empty pattern list
  • Remove delimiters before splitting text
  • Using erase with coding agents
  • FAQ
  • Related Strings functions
  • Transform
  • Text Analytics
  • Core
  • Search
  • Pattern
  • Regex
  • Source you can read
  • About RunMat