var puzzle1=myTrim($("#puzzleinput").val()); function myTrim(x) { return x.replace(/^s+|s+$/gm,''); }