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

strsplit — Split scalar text into substrings using simple or regular-expression delimiters with MATLAB-compatible options.

strsplit(str) splits string-scalar or character-vector text into substrings. It supports MATLAB-compatible delimiter modes, delimiter collapsing, and optional matched-delimiter outputs.

Syntax

[parts, matches] = strsplit(str)
[parts, matches] = strsplit(str, delimiter)
[parts, matches] = strsplit(str, delimiter, Name, Value, ...)
[parts, matches] = strsplit(str, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
strAnyYes—String scalar or character vector input.
delimiterAnyYes—Delimiter scalar/array/cell.
NameStringScalarYes—Option name (`CollapseDelimiters` or `DelimiterType`).
ValueAnyVariadic—Option values and additional Name/Value pairs.

Returns

NameTypeDescription
partsAnySplit tokens.
matchesAnyMatched delimiters when requested as second output.

Returned values from strsplit depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:strsplit:InvalidInputFirst argument is not a string scalar or character vector.strsplit: first argument must be a string scalar or character vector
RunMat:strsplit:DelimiterTypeDelimiter input is not a supported text scalar/array/cell.strsplit: delimiter must be a character vector, string scalar, string array, or cell array of character vectors
RunMat:strsplit:NameValuePairName-value options are not supplied in complete pairs.strsplit: name-value arguments must be supplied in pairs
RunMat:strsplit:UnknownNameAn option name is not recognized.strsplit: unrecognized name-value argument; supported names are 'CollapseDelimiters' and 'DelimiterType'
RunMat:strsplit:EmptyDelimiterDelimiter list is empty or contains empty delimiter entries.strsplit: delimiters must contain at least one character
RunMat:strsplit:DelimiterModeDelimiterType option is not `Simple` or `RegularExpression`.strsplit: value for 'DelimiterType' must be 'Simple' or 'RegularExpression'
RunMat:strsplit:OptionValueOption values are not logical true/false values.strsplit: option values must be logical true or false
RunMat:strsplit:RegexInvalidRegular expression delimiter pattern fails to compile.strsplit: invalid delimiter regular expression
RunMat:strsplit:InternalErrorInternal output container construction failed.strsplit: internal error

How strsplit works

  • The first argument must be scalar text: a string scalar or a character vector. Unlike split, strsplit does not accept string arrays, character matrices, or cell arrays of text.
  • When you omit the delimiter, strsplit splits on MATLAB's default whitespace set (' ', \f, \n, \r, \t, \v) and collapses consecutive delimiters.
  • Explicit delimiters default to 'CollapseDelimiters', true, so adjacent delimiters are grouped unless you opt out.
  • Set 'DelimiterType', 'RegularExpression' to interpret delimiters as regex patterns. In 'Simple' mode, delimiters are matched literally and special regex characters are escaped.
  • String input returns a row string array. Character-vector input returns a row cell array of text elements.
  • Integer values have no text or option role and are not interpreted as delimiters or character codes.

Examples

Split A Character Vector On Whitespace

txt = 'The rain in Spain.';
parts = strsplit(txt)

Expected output:

parts = 1x4 cell
    {'The'}    {'rain'}    {'in'}    {'Spain.'}

Split Using A Literal Delimiter

csv = "alpha,beta,gamma";
parts = strsplit(csv, ",")

Expected output:

parts = 1x3 string
    "alpha"    "beta"    "gamma"

Return The Matched Delimiters

[parts, matches] = strsplit("a,,b,", ",")

Expected output:

parts = 1x3 string
    "a"    "b"    ""

matches = 1x2 string
    ",,"    ","

Use A Regular Expression Delimiter

[parts, matches] = strsplit("1.21m/s 1.985 m/s", "\s*m/s\s*", "DelimiterType", "RegularExpression")

Expected output:

parts = 1x3 string
    "1.21"    "1.985"    ""

matches = 1x2 string
    "m/s "    " m/s"

Preserve Empty Fields

parts = strsplit("a,,b", ",", "CollapseDelimiters", false)

Expected output:

parts = 1x3 string
    "a"    ""    "b"

Using strsplit with coding agents

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

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

FAQ

How is strsplit different from split?⌄

strsplit is the scalar-text API that mirrors MATLAB's older function shape, including optional matches output and regex delimiter mode. split is the vectorized string-array builtin.

What does the second output contain?⌄

The optional matches output returns the delimiter text that produced each split. When delimiters are collapsed, adjacent delimiter runs are grouped into the matched text.

Can strsplit use regular expressions?⌄

Yes. Pass 'DelimiterType', 'RegularExpression' and provide delimiter patterns as regex fragments.

Does strsplit accept string arrays?⌄

No. RunMat currently restricts strsplit to scalar text, matching MATLAB's documented scalar-input API.

Related Strings functions

Transform

append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · 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 strsplit is executed, line by line, in Rust.

  • View the source for strsplit 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 strsplit works
  • Examples
  • Split A Character Vector On Whitespace
  • Split Using A Literal Delimiter
  • Return The Matched Delimiters
  • Use A Regular Expression Delimiter
  • Preserve Empty Fields
  • Using strsplit with coding agents
  • FAQ
  • Related Strings functions
  • Transform
  • Text Analytics
  • Core
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat