Simplify implementation of trim()

This implementation is based on the shim for String.prototype.trim
described in [1].

Instead of extracting the expected substring from the string,
the replace function now removes whitespace from the start and
end of the string.

Reference:
[1] Section: Compatibility
in String.trim
in Mozilla Developer Network
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Compatibility