Use a regex instead of trim so we don't depend on trim in browsers that don't support it.