function trim(s) {

    var rLeft  = /^\s*/;
    var rRight = /\s*$/;

    s = s.replace(rLeft, '');
    return s.replace(rRight, '');

} // function