# Replace functions of an expression by their zeroth derivative

A quick question on handling expressions. Suppose I have an expression like:

z1 == y[-1] + 1/2 y[0] + 2 y''[0] + 3 w'''[-2]

How can I transform it so that the zeroth derivatives are left unevaluated and I get the following expressions :


z1 == Hold[y(0)[-1]] + 1/2 Hold[y(0)[0]] + 2 y''[0] + 3 w'''[-2]


The closest I could get to a solution was using the function:

Replace[#, y_[x_] -> Hold[Derivative[0][y][x]], \[Infinity]]&

But this rather yields


z1 == Hold[y(0)[-1]] + 1/2 Hold[y(0)[0]] + 2 Hold[(y'')(0)[0]] + 3 Hold[(w(3))(0)[-2]]


So the replacement is applied to more than I want it to be.

Almost, try y[x_] :> instead of y_[x_]-> because you need y, not whatever head which pattern you called y.
:> will scope x in case when x has a value. p.s. you may be interested in HoldForm which renders nicely (it is still there though!)
z1 == y[-1] + 1/2 y[0] + 2 y''[0] + 3 w'''[-2] /.