I have:
f[a, b] /. f[x__] -> g[x, 0] // InputForm
(* Out: g[a, b, 0] *)
Which is what I expect, but when I use a built in symbol instead of f
, the result is different, for example:
Times[a, b] /. Times[x__] -> g[x, 0] // InputForm
(* Out: g[a*b, 0] *)
How could I replace the multiplication in this case to get the same result as above?
Times[a, b] /. Verbatim[Times][x__] -> g[x, 0]
orTimes[a, b] /. HoldPattern[Times[x__]] -> g[x, 0]
$\endgroup$Times[a, b] /. Times[x___, y__] :> g[y, 0]
. $\endgroup$