Fixed operator scanning by greedily getting the longest match.