BigQuery 正则表达式从字符串中删除/替换文本列表

AK9*_*K91 2 regex sql google-bigquery

我将如何删除字符串中的文本列表?本质上有一个 URL 列,并且希望避免过长的正则表达式和多个嵌套替换函数。

有没有一种方法可以声明“http”、“www.”等文本列表,并将它们一次性从列中删除?

Mik*_*ant 6

您可以使用以下简单的方法

with t as (
  select 'Is there a way to declare a list of text such as "http", "www.", etc and have them removed from the column in one go?' col
)
select regexp_replace(col, r'http|www.|etc', '') cleaned_col
from t     
Run Code Online (Sandbox Code Playgroud)

带输出

在此输入图像描述