Definition: string text = substitute(string text, string s, string r)
Description: Replace all instances of s in text with r.
Comments: Ideal for extensive text manipulation, eg re-indenting html or stripping tags to leave plain text.

Very long strings that need thousands of replacements are broken up into thousands of chunks and re-assembled once at the end, which makes this far more efficient than an "in situ" operation, since individual characters (in particular the last few) are moved just twice rather than thousands of times.

The Euphoria match_replace() routine offers similar but less efficient functionality, especially when the lengths of s and r differ. The previous replace_all() routine of Euphoria has been deprecated in favour of match_replace(). The Phix implementation of substitute() as found in builtins\substitute.e and reproduced below should work on Euphoria, once all the string types are replaced with sequence types.
?substitute("abracadabra", "ra", "X")       -- displays "abXcadabX"
?substitute("abracadabra", "a", "")         -- displays "brcdbr"
Implementation: See builtins\substitute.e (an autoinclude), reproduced in the technicalia dropdown below, for details of the actual implementation.
See Also: join, tagset