ReplaceAll (/.)

WMA link


ReplaceAll[expr, x -> y]

expr /. x -> y

yields the result of replacing all subexpressions of expr matching the pattern x with y.

expr /. {x -> y, ...}

performs replacement with multiple rules, yielding a single result expression.

expr /. {{a -> b, ...}, {c -> d, ...}, ...}

returns a list containing the result of performing each set of replacements.

If rules is a list of lists, a list of all possible respective replacements is returned:

The list can be arbitrarily nested:

ReplaceAll also can be used as an operator:

ReplaceAll replaces the shallowest levels first:

Replace
ReplaceList