![]() |
|
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).
![]() |