Also, I'd strongly recommend not mutating the passed in string. Instead, consider copying it and mutating that if you must mutate something.