Better matching in nodeIndexToCharIndex and ignoring comments

Updated to use FSM instead of regex.