I am using Google BigQuery table , in that am inserting few records to submit table but for one of the column[manfacturing_output] few categories are coming with sentence so I tried to remove the words which are not needed through regular expression but am unable to resolve issue
output column [manfacturing_output] data looks like this below
manfacturing_output
"The category is "Clamp Break"."
Turner Usability
"The category for the response is "Clamp Break"."
"The category for this response is "Turner Usability"."
Clamp Break
"The category is "Machine & Errors"."
"The category for the response is "Turner Usability"."
I need expected output column looks like this
manfacturing_output
Clamp Break
Turner Usability
Clamp Break
Turner Usability
Clamp Break
Machine & Errors
Turner Usability
I have tried lot of regular expression statements by passing through inside SQL query but it didn’t worked out as expected
Big Query Queries which I tried so far
SELECT REGEXP_EXTRACT(manfacturing_output, r'"([^"]+)"|:(.*)') AS manfacturing_output FROM `sd-map-189360.machinery.ent_supp_eng`
SELECT REGEXP_EXTRACT(manfacturing_output, r'"([^"]+)"|:(w+)') AS manfacturing_output FROM `sd-map-189360.machinery.ent_supp_eng`
SELECT REGEXP_EXTRACT(manfacturing_output, r""(.*?)"") AS manfacturing_output FROM `sd-map-189360.machinery.ent_supp_eng`
SELECT
CASE
WHEN REGEXP_CONTAINS(manfacturing_output, r'"([^"]+)"') THEN REGEXP_EXTRACT(manfacturing_output, r'"([^"]+)"')
WHEN REGEXP_CONTAINS(manfacturing_output, r'The predicted category is: (.*)') THEN REGEXP_EXTRACT(manfacturing_output, r'The predicted category is: (.*)')
ELSE TRIM(REGEXP_REPLACE(manfacturing_output, r'.*"(.*)".*', '\1'))
END AS manfacturing_output
FROM `sd-map-189360.machinery.ent_supp_eng`
1