Replace all pi question


the code explain in this question doesn’t work for all pi
for ex :-abpicdpipi
it gives output as ab3.14cd3.14pi
so what is the general code to replace all pi