Navigation
Synopsis Replace the last occurrence of a string in another string.
Function str replaceLast(str subject, str find, str replacement)
Usage import String;
Description Return a copy of subject in which the last occurrence of find (if it exists) has been replaced by replacement. Also see replaceFirst and replaceLast.
Examples
rascal>import String;
ok
rascal>replaceLast("abracadabra", "a", "A");
str: "abracadabrA"
rascal>replaceLast("abracadabra", "ra", "RARA");
str: "abracadabRARA"
rascal>replaceLast("abracadabra", "cra", "CRA");
str: "abracadabra"
Pitfalls Note that find is a string (as opposed to, for instance, a regular expression in Java).
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.