JavaScript TRIM NEWLINE

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