/**
 * @file: String.js
 * @title: String
 * @description: 扩展 String
 * @copyright: Copyright (C) 2007 Lynn
 */

//
String.prototype.contains = function (str)
{
	return (this.indexOf(str) > -1);
};

//
String.prototype.equals = function ()
{
	for (var i = 0; i < arguments.length; i++)
	{
		if (this == arguments[i])
		{
			return true;
		}
	}
	return false;
};

//
String.prototype.startsWith = function (str)
{
	return (this.substr(0, str.length) == str);
};

//
String.prototype.endsWith = function (strA, strB)
{
	var strC = this.length;
	var strD = strA.length;
    if (strD > strC)
	{
		return false;
	}
    if (strB)
	{
		var strE = new RegExp(strA + "$", "i");
		return E.test(this);
	}
	else
	{
		return (strD == 0 || this.substr(strC - strD, strD) == strA);
	}
};

//
String.prototype.remove = function (strA, strB)
{
	var s = "";
	if (strA > 0)
	{
		s = this.substring(0, strA);
	}
	if (strA + strB < this.length)
	{
		s += this.substring(strA + strB, this.length);
	}
	return s;
};

//
String.prototype.trim = function ()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
};

//
String.prototype.ltrim = function ()
{
	return this.replace(/^\s*/g, "");
};

//
String.prototype.rtrim = function ()
{
	return this.replace(/\s*$/g, "");
};

//
String.prototype.replaceNewLineChars = function (str)
{
	return this.replace(/\n/g, str);
};

