JSFiddle - React, Tailwind, and code Playground
JavaScript
String.prototype.strim = function(needle) {
var out = this;
while (0 === out.indexOf(needle))
out = out.substr(needle.length);
while (out.length === out.lastIndexOf(needle) + needle.length)
out = out.slice(0,out.length-needle.length);
return out;
}
var spam = "this is a string. this ends with thisthis";
alert("#" + spam.strim("this") + "#");