This question is related to Carry out substring replacement on variable's contents. Is it possible to perform string replace on an arbitrary string, without expansion? MWE:
\documentclass{article}
\usepackage{xstring}
\begin{document}
\noexpandarg
\StrSubstitute{John \textit{knows} that Mary is a unicorn}{knows}{believes}
\end{document}
With this MWE, nothing is replaced. Desired behaviour is a replacement of \textit{knows} with \textit{believes}, i.e., verbatim, plain replacement. Also, e.g., \StrSubstitute{\textit{knows}}{tex}{latex} should result in \latexit{knows} (i.e., replacement should consider the string as given, without taking any internal semantics into consideration).
A pdflatex solution is preferred (no lua, perl, sed, text editor search and replace). xstring is not required.

