replaced trim with regex for older browsers
better regex
Merge pull request #4 from smhg/master

old browser compatibility