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