.replace(/^\s+|\s+$/gm,'');

trim out whitespaces if table from html is filled with a href or data-attrib's