Modified regex to avoid matching identifiers containing characters '?' or '#'