add contains() function to string library. added tests too.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@859 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-03 19:54:00 +00:00
parent 74b3e153f8
commit 65ae34d4e7
2 changed files with 17 additions and 1 deletions

View File

@@ -561,6 +561,16 @@ String.prototype.startsWith = function(sStart){
return (this.substr(0,sStart.length) == sStart);
};
/**
* @param {String} str
*
* @returns Whether or not this string contains with the string passed in.
* @type Boolean
*/
String.prototype.contains = function(str){
return (this.indexOf(str) != -1);
};
/**
* @returns A trimmed version of the string - all leading and
* trailing spaces removed