This is probably easier and faster as just `ip.replace(/\.[^.]*$/,'')`