Fix trim not existing

Trim function appears not to exist, so replace with replace method to
trim text.