The problem is that something this basic is considered a complete library. If you know regex you could write this on your coffee break. If you don't, you could look it up and still write in on your coffee break. If you want trim and do anything else with a string, you need another dependency tree.
This is not even really a problem with javascript lacking a standard library, so much as a problem with the accepted practices of the javascript community.