fixed matchRegExp function