Trim

function trim (s)
{
    return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}