I'm trying to extract the following data and convert it to a final column in BigQuery.
Raw Data SAY LOWERS = BAD.Q Virginia SAY LOWERS = BAD.U Oregon Georgia SAY LOWERS = BAD.U SAY LOWERS = BAD.A California
Final Version BAD.Q Virginia BAD.U Oregon Georgia BAD.U BAD.A California
Basically, I'm trying to remove "SAY LOWERS = " from all the data that has it, and keep everything after it, and keep everything that doesn't have that phrase.
CodePudding user response:
This answer covers how to run regexp_replace
in Google BigQuery, here is the query adapted for your use case:
SELECT regexp_replace(your_column_name, r'SAY LOWERS = ', '') final_column_name
FROM your_table_name
CodePudding user response:
You don't need a regex to remove a constant string from another one. Just use REPLACE
:
SELECT REPLACE(your_column, 'SAY LOWERS = ', '') AS final_column
FROM your_table