/**
 * Some additional methods to add to the standard JavaScript String object
 * 
 * @author Assem Hakmeh
 * @date 2011-01-20
 */


/**
 * trim - Use regular expressions to trim whitespace from beginning and end of a string
 * @returns {String}
 */
String.prototype.trim = function() {
	return this.replace(/^\s+ | \s+$/g,'')
}

/**
 * right - return the specified number of chars from the right end of a string
 * @param count number of chars to return
 * @returns {String}
 */
String.prototype.right = function(count) {
	return this.substr(this.length - count);
}

/**
 * left - return the specified number of chars from the left end of a string
 * @param count number of chars to return
 * @returns {String}
 */
String.prototype.left = function(count) {
	return this.substr(0, count);
}

/**
 * isBlank - Tests if the string is undefined or consists of 0 or more whitespace chars.
 * @param str
 * @returns {Boolean}
 */
String.prototype.isBlank = function() {
    return (/^\s*$/.test(this));
}

function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}

/**
 * isEmpty - Tests if the string is undefined or is a zero-length 
 * @param str
 * @returns {Boolean}
 */
String.prototype.isEmpty = function() {
    return (0 === this.length);
}

function isEmpty(str) {
    return (!str || 0 === str.length);
}


