I'm trying to use ReplaceAll
in a subscript. However, it doesn't seem to work as expected if I want to use the output the subscript in a ToString
. See below:
Subscript[A, 1] /. Subscript[A, x_] -> x
Subscript[A, 1] /. Subscript[A, x_] -> ToString[x]
Subscript[A, 1] /. Subscript[A, x_] -> f[x]
1 x f[1]
The first and third cases are resulting in the expected output, but ToString
seems to have some special attribute that doesn't allow the replacement rule to process in the second case. What is causing this behaviour?