replace. Replacing substrings in the string


Replaces substrings in the
string using substitution settings.

Table_with_substitution_settings is an object of class table, containing two columns:

The first contains the substring to be replaced.
The second contains the substring to replace the first one.

It is not necessary to specify column names - you may call it 'from' and 'to' or simply skip naming by using
nameless table.

$s[An ugly moment I'll remember!]
Original: $s<br />
table::create{from   to
n   A
ugly   magic}]
After replace^s.replace[$rep]

The code will output:

Original: An ugly moment I'll remember!
fter replace: A magic moment I'll remember!

Copyright © 1997–2017 Art. Lebedev Studio | Last updated: 18.06.2012