gives a list of the sublists in list that match the sequence pattern patt.


gives a list of the values of rhs corresponding to sublists that match patt.


includes only the first n matches.

Details and Options

  • In SequenceCases[list,patt], patt can be an expression with head List that includes pattern constructs such as PatternSequence, Repeated (..), Blank (_), and BlankSequence (__).
  • The pattern patt can also be a pattern that matches a list but does not itself have head List.
  • With the default option setting OverlapsFalse, SequenceCases includes only sublists that do not overlap. With the setting OverlapsTrue, it includes sublists that overlap.
  • With Overlaps->All, multiple sublists that match the same pattern are all included. With Overlaps->True, only the first such matching sublist at a given position is included.


open allclose all

Basic Examples  (2)

Find sublists that match a pattern:

Perform a replacement on each match:

Count the length of all contiguous sequences of b:

Scope  (3)

Find sequences of elements that match a pattern:

Find all overlapping sequences in a list:

Evaluate a function on the cases found:

Options  (2)

Overlaps  (2)

Allow overlaps:

Allow no overlaps:

Allow overlaps starting at different positions:

Allow no overlaps:

Allow all overlaps:

Properties & Relations  (3)

Find the position of a sequence:

Find the actual sequence:

Count the number of cases:

Replace the sequence by an expression:

For lists of characters, SequenceCases is similar to StringCases:

SubsetCases matches the elements of the sequence in any order:

SequenceCases matches the sequence only in the specified order:

Wolfram Research (2015), SequenceCases, Wolfram Language function,


Wolfram Research (2015), SequenceCases, Wolfram Language function,


Wolfram Language. 2015. "SequenceCases." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2015). SequenceCases. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_sequencecases, author="Wolfram Research", title="{SequenceCases}", year="2015", howpublished="\url{}", note=[Accessed: 16-June-2024 ]}


@online{reference.wolfram_2024_sequencecases, organization={Wolfram Research}, title={SequenceCases}, year={2015}, url={}, note=[Accessed: 16-June-2024 ]}