SequenceSplit[list,patt]
splits list into sublists separated by sequences that match the sequence pattern patt.
SequenceSplit[list,pattrhs]
inserts rhs at the position of each matched sequence.
SequenceSplit[list,{patt1rhs1,…}]
inserts rhsi at the position of each patti.
SequenceSplit[list,patt,n]
splits into at most n sublists.
SequenceSplit
SequenceSplit[list,patt]
splits list into sublists separated by sequences that match the sequence pattern patt.
SequenceSplit[list,pattrhs]
inserts rhs at the position of each matched sequence.
SequenceSplit[list,{patt1rhs1,…}]
inserts rhsi at the position of each patti.
SequenceSplit[list,patt,n]
splits into at most n sublists.
Details
- SequenceSplit[list,patt] by default gives the list of sublists of list that occur between sequences defined by patt; it does not include the sequences themselves.
- SequenceSplit[list,{patt1rhs1,…,patta,…}] includes rhsi at the position of sequences matching patt1 but omits sequences matching patta.
Examples
open all close allBasic Examples (3)
Split at sequences that match a pattern:
SequenceSplit[{x, x, a, b, y, a, c, z}, {a, _}]Insert an expression at the position of the matched sequences:
SequenceSplit[{x, x, a, b, y, a, c, z}, {a, e_} :> {e}]Split into at most 2 sublists:
SequenceSplit[{x, x, a, b, y, a, c, z}, {a, _}, 2]Scope (6)
Use a pattern to split the original list:
SequenceSplit[{1, "a", "a", 2, 3, "b", "b", 4, 5}, {"a", "a"}]Use a rule to replace the matched sequences:
SequenceSplit[{1, "a", "a", 2, 3, "b", "b", 4, 5}, {_String, _String} -> "X"]Split the original list at sequences that match any of the patterns:
SequenceSplit[{1, 2, 3, 4, 5, 6, 7}, {2, 3} | {6}]Use a list of rules to replace the matched sequences:
SequenceSplit[{1, 2, 3, 4, 5, 6, 7}, {{2, 3} -> "X", {6} -> "Y"}]SequenceSplit[{1, 2, 3, 4, 5, 6, 7}, {{2, 3} -> "X", {6}}]Split into at most 2 sublists:
SequenceSplit[{a, b, 1, 2, c, d, 3, 4, e, f}, {__Integer}, 2]Applications (1)
Properties & Relations (8)
Insert a list of elements at the position of the matched sequence:
SequenceSplit[{1, 2, 3, 4, 5}, {2, 3} -> {a, b}]Use Sequence instead of List to splice the elements in the output list:
SequenceSplit[{1, 2, 3, 4, 5}, {2, 3} -> Sequence[a, b]]Rules are tried in the given order:
list = {1, 2, "a", "b", 3, 4, "c", "d"};SequenceSplit[list, {{_Integer} -> "X", {_Integer, _Integer} -> "Y"}]SequenceSplit[list, {{_Integer, _Integer} -> "Y", {_Integer} -> "X"}]A list of sublists is considered as a single sequence pattern:
SequenceSplit[{1, "a", 2, "b", 3, "c", 4}, {{"a"}, {"b"}, {"c"}}]SequenceSplit[{1, 2, {"a"}, {"b"}, {"c"}, 3, 4}, {{"a"}, {"b"}, {"c"}}]Use Alternatives to split at any of the sequence subpatterns:
SequenceSplit[{1, "a", 2, "b", 3, "c", 4}, Alternatives[{"a"}, {"b"}, {"c"}]]The third argument of SequenceSplit is the count of sublists not considering insertions:
SequenceSplit[{x, x, a, b, y, a, c, z}, {a, _}]SequenceSplit[{x, x, a, b, y, a, c, z}, {a, _}, 2]SequenceSplit[{x, x, a, b, y, a, c, z}, {a, e_} :> e, 2]Split a list into sublists delimited by sequences that match a pattern:
SequenceSplit[{a, b, 1, 2, c, d, 3, 4}, {__Symbol}]Replace a sequence by an expression:
SequenceReplace[{a, b, 1, 2, c, d, 3, 4}, {__Symbol} -> "X"]Find the position of the sequence:
SequencePosition[{a, b, 1, 2, c, d, 3, 4}, {__Symbol}, Overlaps -> False]SequenceCases[{a, b, 1, 2, c, d, 3, 4}, {__Symbol}, Overlaps -> False]SequenceCount[{a, b, 1, 2, c, d, 3, 4}, {__Symbol}, Overlaps -> False]Split at any sequence of integers:
SequenceSplit[{a, 1, b, c, 2, 3, d, e, f}, {__Integer}]Use SequenceCases instead:
SequenceCases[{a, 1, b, c, 2, 3, d, e, f}, {Except[_Integer]..}]For lists of characters, SequenceSplit is similar to StringSplit:
text = "On 31/12/2003 we left, and on 5/3/2004 we came back.";Map[StringJoin, SequenceSplit[Characters[text], {"w", "e"} -> "they"]]StringSplit[text, "we" -> "they"]SequenceSplit[{1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5}, {x__ ? EvenQ} :> {x}]Compare with SplitBy:
SplitBy[{1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5}, EvenQ]Related Guides
History
Text
Wolfram Research (2018), SequenceSplit, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceSplit.html.
CMS
Wolfram Language. 2018. "SequenceSplit." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceSplit.html.
APA
Wolfram Language. (2018). SequenceSplit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceSplit.html
BibTeX
@misc{reference.wolfram_2026_sequencesplit, author="Wolfram Research", title="{SequenceSplit}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceSplit.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sequencesplit, organization={Wolfram Research}, title={SequenceSplit}, year={2018}, url={https://reference.wolfram.com/language/ref/SequenceSplit.html}, note=[Accessed: 13-June-2026]}