python:

result.strip()

java:

result.trim();

swift:

result.trimmingCharacters(in: NSCharacterSet.whitespaces)