No need to create these temporary strings - find_first_of takes a position as well.

You should only need three sub strings.