JavaScript Trim Newline

str = str.replace(/^\s+|\s+$/g, '');
Friendly Hawk