ReplaceAll
expr /. rule replaces all occurences of the LHS of rule with the RHS of rule in expr.
expr /. {r1, r2, ...} performes the same operation as expr /. rule, but evaluating each r_n in sequence.
Attributes[ReplaceAll] := {Protected}
Simple examples
If no match is found,ReplaceAll evaluates to an unchanged expr:
ReplaceAll works within Orderless expressions as well (such as Plus):
ReplaceAll can use named patterns:
Further examples
ReplaceAll can be used to replace sequences of expressions:
Head of functions can be replaced just as the subexpressions: