Logo

Programming-Idioms

History of Idiom 296 > diff from v5 to v6

Edit summary for version 6 by Bart:
New Pascal implementation by user [Bart]

Version 5

2022-02-17, 17:54:32

Version 6

2022-02-17, 17:59:39

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
Code
  x2 := ReverseString(StringReplace(ReverseString(x), ReverseString(y), ReverseString(z), []));
Comments bubble
Just fort the fun of doing it in a one-liner...