solve the rangeOfstring problem