Cases

WMA link


Cases[list, pattern]

returns the elements of list that match pattern.

Cases[list, pattern, ls]

returns the elements matching at levelspec ls.

Cases[list, pattern, Heads->bool]

Match including the head of the expression in the search.

Find symbols among the elements of an expression:

Also include the head of the expression in the previous search:

AppendTo
Count