ReplaceList

WMA link


ReplaceList[expr, rules]

returns a list of all possible results when applying rules to expr.

ReplaceList[expr, rules, n]

returns a list of at most n results when applying rules to expr.

Get all subsequences of a list:

You can specify the maximum number of items:

If no rule matches, an empty list is returned:

Like in ReplaceAll, rules can be a nested list:

Possible matches for a sum:

ReplaceAll
ReplaceRepeated