Algosim documentation: StringReplace

StringReplace

Searches a string for a substring and replaces all found occurrences with a new text.

Syntax

Description

If s and x are strings, then StringReplace searches s for x and replaces all found occurrences of x with y.

f specifies flags for the algorithm. It is a string that can contain zero or more of the following characters:

If omitted, f defaults to "" (no options).

Finally, if δ is specified, StringReplace will begin searching s for x at character index δ in s (the first character having index 1).

Examples

Alice ≔ ExampleData("Alice in Wonderland");
StringReplace(Alice, "Alice", "Harry", "i")
Harry’S ADVENTURES IN WONDERLAND

Lewis Carroll

THE MILLENNIUM FULCRUM EDITION 3.0




CHAPTER I. Down the Rabbit-Hole

Harry was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, ‘and what is the use of a book,’ thought Harry ‘without pictures or
conversations?’

So she was considering in her own mind (as well as she could, for the
hot day made her feel very sleepy and stupid), whether the pleasure
of making a daisy-chain would be worth the trouble of getting up and
picking the daisies, when suddenly a White Rabbit with pink eyes ran
close by her.

There was nothing so VERY remarkable in that; nor did Harry think it so
VERY much out of the way to hear the Rabbit say to itself, ‘Oh dear!
Oh dear! I shall be late!’ (when she thought it over afterwards, it
occurred to her that she ought to have wondered a…