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.
i = index(s,w,back=.true.) - 1
if (i == len(s) - len(w) ) then
allocate (t, source=s(:i))
else
allocate (t, source=s)
end if
const t = s.endsWith(w) ? s.slice(0, -w.length) : s
int i = s.lastIndexOf(w),
m = s.length(), n = w.length();
t = i == m - n ? s.substring(0, i) : s;
String t = s;
int index = s.lastIndexOf(w);
if (index + w.length() == s.length()) {
t = s.substring(0, index);
}
local t = s:gsub(w.."$", "")
preg_replace("/{$w}$/u", '', $s);
if (length $s == rindex($s, $w) + length $w) {
my $t = substr $s, 0, rindex $s, $w;
}
t = s.removesuffix(w)
t = s.sub(/#{w}\z/, "")
t = s.delete_suffix(w)
let t = s.strip_suffix(w).unwrap_or(s);
let t = s.trim_end_matches(w);