asManyOfPattern
Pattern that matches another pattern repeatedly, taking as many repetitions as possible.
Category: Language Fundamentals > Data Types
Syntax
newPat = asManyOfPattern(pat)
Matches pat one or more times, greedily.
newPat = asManyOfPattern(pat, minLength)
Requires at least minLength repetitions.
Description
The pattern consumes as many consecutive repetitions of pat as it finds, then lets the rest of a larger pattern continue from there. If a later part fails, it gives repetitions back until a match is possible.
It is the pattern-object equivalent of the + quantifier in a regular expression. A run shorter than minLength is not matched.
Input arguments
pat- A pattern, or text that is converted to a pattern.
minLength- Minimum number of repetitions.
Output arguments
newPat- A
patternobject.
Example
Runs of a letter
extract('aaabaa', asManyOfPattern('a'))
extract('aaabaa', asManyOfPattern('a', 3))
Output
ans = 2×1 string array
"aaa"
"aa"
ans = "aaa"
See also
asFewOfPattern optionalPattern lettersPattern extract pattern