possessivePattern
Description
creates a pattern that does not backtrack within newpat
= possessivePattern(pat
)pat
once
pat
matches.
If a character may be matched by more than one pattern in an expression, such as digit
characters with alphanumericsPattern + digitsPattern
, all possible
combinations of matching may be tested in an attempt to find a successful match. This
process is called backtracking.
possessivePattern
prevents backtracking, so once a
possessivePattern
matches, the matched text is no longer able to be
matched by other parts of the pattern expression, even if that causes the pattern to fail to
match. Use possessivePattern
to improve performance by limiting the
possible pattern combinations tested to find a match.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2020b