// *************
// Objet String
// *************

String.prototype.trim = function(ch) {
	var x = this;

	x = x.trimL(ch);
	x = x.trimR(ch);

	return x;
}

String.prototype.trimL = function(ch) {
	var x = this;

	// Caractère d'echappement
	if(ch == undefined) {
		x = x.replace(/^\s*(.*)/, "$1");
		return x;
	}

	// Autre caractère
	while(x.charAt(0) == ch) {
		x = x.substr(1);
	}
	return x;
}

String.prototype.trimR = function(ch) {
	var x = this;

	// Caractère d'echappement
	if(ch == undefined) {
		x = x.replace(/(.*?)\s*$/, "$1");
		return x;
	}

	// Autre caractère
	while (x.charAt(x.length - 1) == ch) {
		x = x.substr(0, x.length - 1);
	}
	return x;
}
