e.g. if cell A1 contains the function `=SUM(B1:B6)` is there a way I could use a formula like `SUBSTITUTE(A1,"SUM","COUNT")` to return the formula `=COUNT(B1:B6)`?

Alternatively, is there a formula that will return what has been entered - i.e. return `=SUM(B1:B6)` as a string instead of the value?