Finds the index of a given string in another string that is closest to the given position in the given direction.