Cadabra

replace_match

Put the result of a sub-computation back into the original expression
This algorithm is the partner of take_match; see the documentation of that algorithm for further details.