﻿/**
 *  Author:  Marciano Studio
 *  Web: www.marciano.mx
 *  Version: 1.0
 *  Last Modified: August 5th, 2009
 */

///
/// Strips any letter from a string and returns only numbers(negative or positive)
///
function getNumbers (str) 
{
    str = str.toString();
    var rExpression = /[^-\d]/g;
    return str.replace (rExpression, "");
}

///
/// Strips any space or specified char from the start and the end of a string
///
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

///
/// Strips any space or specified chars from the start of a string
///
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

///
/// Strips any space or specified chars from the end of a string
///
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}