-- Assuming your table is named device_stats SELECT Device_Type, REGEXP_REPLACE( REGEXP_REPLACE( Stats_Access_Link, E'https?://([^<]+)', '\\1', 'g' ), E'[^a-zA-Z0-9\\._]+', '', 'g' ) AS Extracted_URL FROM device_stats;