lookAheadBoundary - Match boundary before specified pattern - MATLAB (original) (raw)
Main Content
Match boundary before specified pattern
Since R2020b
Syntax
Description
[newpat](#mw%5F74800f1c-ec2f-4f57-8dc9-ca9fdd7769c3%5Fsep%5Fmw%5F2527cdca-90c8-43b1-8ea8-8fa52700322c) = lookAheadBoundary([pat](#mw%5F74800f1c-ec2f-4f57-8dc9-ca9fdd7769c3%5Fsep%5Fmw%5F619a0af2-3091-404f-9c61-e268bcf7fbcb))
creates a pattern that matches the start of pat
. Text matched bypat
is not included in the result. lookAheadBoundary
can be negated using the ~
operator. When negated,~lookAheadBoundary
matches between any characters that are not at the start of pat
.
Examples
Create a pattern that matches ahead of "b"
or "2"
.
txt = "abc 123"; pat = lookAheadBoundary("b"|"2");
Use replace
to insert "|"
characters at the matched boundaries.
Use the ~
operator to negate lookAheadBoundary
.
Create a pattern that matches digits except for those directly precede "b"
or "2"
.
txt = "abc 123"; pat = ~lookAheadBoundary("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