I have the string $var in which I need to replace some text. The first \"X\" needs to be replaced by \"A\", the second \"X\" needs to be replaced by B and so on, here is an exam
Yet one more solution (more for a dynamic number of Xs):
I also added the \b in to the pattern to only replace Xs that are free-standing, so "FAUX PAS X" only replaces the last X.
\b
demo
alphabet_replace (more modular form)