Expand/Shrink

substitute_all

Definition: sequence text = substitute_all(sequence text, strings, replacements)
Description: Replace all instances of each string in strings in text with the corresponding string in replacements.
pwa/p2js: Supported.
Comments: A simple wrapper to substitute, allowing multiple strings to be substituted in one call.
Example 1:
constant {hchars,hsubs} = columnize({{"<","&lt;"},
                                     {">","&gt;"},
                                     {"&","&amp;"},
                                     {`"`,"&quot;"},
                                     {`'`,"&apos;"}})
function xmlquote(string s)
    return substitute_all(s,hchars,hsubs)
end function
Example 2: You can also use a pair of strings for simple letter subsitution.
?substitute_all("One fine day in the middle of the night.","aeiou","AEIOU")
-- displays "OnE fInE dAy In thE mIddlE Of thE nIght."
Implementation: See builtins\substitute.e (an autoinclude) for details of the actual implementation.
See Also: join, tagset