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

extractBetween — Extract substrings between boundary markers in MATLAB and RunMat.

extractBetween(text, start, stop) returns text between two markers. Numeric positions accept single, double, and all eight integer classes as one-based structural controls.

Syntax

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

Inputs

str
Type
Any
Required
Yes
Description
Input text scalar/array/cell.
start
Type
Any
Required
Yes
Description
Start boundary marker text or positive integer position(s).
end
Type
Any
Required
Yes
Description
End boundary marker text or positive integer position(s).
Name
Type
StringScalar
Required
Yes
Description
Option name (`Boundaries`).
Value
Type
Any
Required
Variadic
Description
Option value and additional Name/Value pairs.
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

newText
Type
Any
Description
Extracted text preserving scalar/array/cell text container semantics.
NameTypeDescription
newTextAnyExtracted text preserving scalar/array/cell text container semantics.

Errors

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

Text and boundaries

extractBetween(str,start,stop) accepts two text/pattern markers or two numeric positions. A string input produces strings; a character-vector input produces a cell containing a character vector; a cell input preserves its cell layout and element text kinds. Row-wise character matrices are a RunMat extension.

Text markers are excluded by default. Numeric endpoint positions are included by default. The Boundaries option selects inclusive or exclusive handling explicitly. The first start marker and the first following stop marker determine each result; an unmatched marker produces empty text in the current implementation.

Documented boundary arrays are scalar or the same size as the text input. RunMat mode additionally permits compatible broadcasting for string output. Positions use exact one-based integer parsing. Mixed text and numeric boundary domains are rejected.

Typed missing subject or marker elements propagate a missing string result. Every literal spelling, including <missing>, is ordinary text. Independent MATLAB parity for missing-marker overloads remains unqualified.

Placement and effects

Extraction executes on host text without a GPU kernel or fusion route. Numeric or resident text input is rejected before provider access. RunMat mode can admit a resident numeric position control and gather it before host extraction; MATLAB-compatible mode rejects that extension before gathering.

The operation is pure, may throw on invalid inputs, options or output construction, and may suspend while gathering an admitted resident position. It does not access the workspace, filesystem, clock, randomness, or callbacks.

Examples

Extract between text markers

txt = "RunMat accelerates MATLAB workloads";
segment = extractBetween(txt, "RunMat ", " workloads")

Expected output:

segment = "accelerates MATLAB"

Include text markers

path = "snapshots/run/fusion.mat";
withMarkers = extractBetween(path, "snapshots/", ".mat", "Boundaries", "inclusive")

Expected output:

withMarkers = "snapshots/run/fusion.mat"

Use one-based numeric positions

name = "Accelerator";
middle = extractBetween(name, 3, 7)

Expected output:

middle = "celer"

Apply scalar markers to an array

files = ["runmat_accel.rs", "runmat_gc.rs"; "runmat_plot.rs", "runmat_cli.rs"];
stems = extractBetween(files, "runmat_", ".rs")

Expected output:

stems = ["accel", "gc"; "plot", "cli"]

Extract row by row from a character matrix

chars = char("Device<GPU>", "Planner<Fusion>");
tokens = extractBetween(chars, "<", ">")

Expected output:

tokens = ['GPU   '; 'Fusion']

Preserve cell element text kinds

C = {'<missing>', 'A<B>C'; "Planner <Fusion>", "Device<GPU>"};
out = extractBetween(C, "<", ">")

Expected output:

out = {'missing', 'B'; "Fusion", "GPU"}

Propagate missing string values

txt = [missing, "Planner<GPU>"];
tokens = extractBetween(txt, "<", ">")

Expected output:

tokens = [<missing>, "GPU"]

Observe an unmatched marker

value = extractBetween("abc", "x", "c")

Expected output:

value = ""

Using extractBetween with coding agents

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

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

FAQ

Which argument types does extractBetween accept?⌄

The documented text input is a string array, character vector, or cell array of character vectors. Both boundaries are text/pattern markers or both are numeric positions; all eight integer classes are accepted as exact position controls. RunMat mode also admits row-wise character matrices and broader text cells.

Can the start and end arguments mix text and numeric positions?⌄

No. Both boundaries must use the same domain.

What happens when a boundary is not found?⌄

The current implementation returns empty extracted text. This behavior is recorded as RunMat behavior rather than independently verified MATLAB parity.

How does Boundaries inclusive work with numeric positions?⌄

Inclusive mode includes both indexed characters. Exclusive mode returns only the characters strictly between them.

Does extractBetween support implicit expansion?⌄

MATLAB-compatible mode permits scalar or same-size boundaries. General compatible broadcasting is a gated RunMat extension and cannot expand character or cell text output.

Are GPU inputs supported?⌄

There is no GPU text kernel. RunMat mode may gather a resident numeric position control; resident numeric text is rejected without provider access.

Related Strings functions

Transform

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

  • View the source for extractBetween 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
  • Text and boundaries
  • Placement and effects
  • Examples
  • Extract between text markers
  • Include text markers
  • Use one-based numeric positions
  • Apply scalar markers to an array
  • Extract row by row from a character matrix
  • Preserve cell element text kinds
  • Propagate missing string values
  • Observe an unmatched marker
  • Using extractBetween with coding agents
  • FAQ
  • Related Strings functions
  • Transform
  • Text Analytics
  • Core
  • Search
  • Pattern
  • Regex
  • Source you can read
  • About RunMat