Given a string and a position, it finds the position of the token matching the one at the given position.