Given the examplary expression
expr = (x1 + x17 y2 )/Sqrt[y1 + xx3]
I want to apply a rule for every symbol-name starting with "x".
My solution
expr /. x_ :>f[x] /; And[Head[x] == Symbol, StringTake[ToString[x], 1] =="x"]
(* (f[x1] + y2 f[x17])/Sqrt[y1 + f[xx3]] *)
works but seems to be very complicated.
How could I simplify my approach? Thanks.
->3you have:>f[x]. The fact there isn't anything shorter there suggests that is the way to go. Unless you want to see an answer like: "no, go with linked topic". – Kuba Mar 08 '18 at 09:43