Logo

Programming-Idioms

History of Idiom 296 > diff from v6 to v7

Edit summary for version 7 by Bart:
[Pascal] Fix typo in comment

Version 6

2022-02-17, 17:59:39

Version 7

2022-02-17, 18:00:12

Idiom #296 Replace last occurrence of substring

Assign to x2 the value of string x with the last occurrence of y replaced by z.
If y is not contained in x, then x2 has the same value as x.

Idiom #296 Replace last occurrence of substring

Assign to x2 the value of string x with the last occurrence of y replaced by z.
If y is not contained in x, then x2 has the same value as x.

Variables
x2,x,y,z
Variables
x2,x,y,z
Extra Keywords
substring substitute
Extra Keywords
substring substitute
Imports
StrUtils
Imports
StrUtils
Code
  x2 := ReverseString(StringReplace(ReverseString(x), ReverseString(y), ReverseString(z), []));
Code
  x2 := ReverseString(StringReplace(ReverseString(x), ReverseString(y), ReverseString(z), []));
Comments bubble
Just fort the fun of doing it in a one-liner...
Comments bubble
Just for the fun of doing it in a one-liner...