Logo

Programming-Idioms

Set i to the position of the last occurrence of the string y inside the string x, if exists.

Specify if i should be regarded as a character index or as a byte index.

Explain the behavior when y is not contained in x.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import "strings"
i := strings.LastIndex(x, y)
StrUtils
i := RPos(y,x);
i = x.rfind(y)
i = x.rindex(y)
let i = x.rfind(y);