lookBehindBoundary - Match boundary following specified pattern - MATLAB (original) (raw)
Main Content
Match boundary following specified pattern
Since R2020b
Syntax
Description
[newpat](#mw%5F5782a723-dafd-4280-a818-60e415878935%5Fsep%5Fmw%5F2527cdca-90c8-43b1-8ea8-8fa52700322c) = lookBehindBoundary([pat](#mw%5F5782a723-dafd-4280-a818-60e415878935%5Fsep%5Fmw%5F619a0af2-3091-404f-9c61-e268bcf7fbcb))
creates a pattern that matches the end of pat
. Text matched bypat
is not included in the result.lookBehindBoundary
can be negated using the ~
operator. When negated, ~lookBehindBoundary
matches between any characters that are not at the end of pat
.
Examples
Create a pattern that matches behind "b"
or "2"
.
txt = "abc 123"; pat = lookBehindBoundary("b"|"2");
Use replace
to insert "|"
characters at the matched boundaries.
Use the ~
operator to negate lookBehindBoundary
.
Create a pattern that matches digits except for those that directly follow "b"
or "2"
.
txt = "abc 123"; pat = ~lookBehindBoundary("b"|"2");
Use replace
to insert "|"
characters at the negated boundaries.
Input Arguments
Input pattern, specified as a pattern, string array, character vector, or cell array of character vectors.
Data Types: char
| string
| pattern
| cell
Output Arguments
Output pattern, returned as a pattern or an array of pattern objects.
Extended Capabilities
Version History
Introduced in R2020b