JSFiddle - React, Tailwind, and code Playground

JavaScript

String.prototype.replaceSome = function() {
	var replaceWith = Array.prototype.pop.apply(arguments),
		i = 0,
		r = this,
		l = arguments.length;
	for (;i<l;i++) {
		r = r.replace(arguments[i],replaceWith);
	}
	return r;
}

/* 
replaceSome method for strings
it takes as ,much arguments as we want and replaces all 
of them with the last argument we specified 
2013 CopyRights saved for: Max Ahmed
this is an example:
*/
var string = "[hello i want to 'replace x' with eat]";
var replaced = string.replaceSome("]","[","'replace x' with","");
alert(string + ", " + replaced); // returns hello i want to eat (without brackets)