use replace rather than trim (greater browser support)