Skip to content
Advertisement

SQL: Remove part of string that is in another column of the table using REGEXP_REPLACE

I have a column that looks like so, but with more rows:

Now, I am trying to remove the cat name from the message on each row in the table, so that I can see what the messages sent to each cat are, and which cats got the same message (i.e. this way I would be able to see that Garfield and RoseMary got identical messages).

I attempted to solve this with regexp_replace (where I want to replace the CatName part of each Message with nothing — but I think I am getting it wrong*. Anyone who can see where I err, or have a better suggestion for how I solve this issue?

  • BigQuery throws this error: Cannot parse regular expression: bad repetition operator: ???

Advertisement

Answer

Why not just use replace()?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement