【问题标题】:BigQuery regex remove/replace a list of text from a stringBigQuery 正则表达式从字符串中删除/替换文本列表
【发布时间】:2021-03-12 02:23:50
【问题描述】:

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

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

【问题讨论】:

  • 请提供样本数据和期望的结果。

标签: sql regex google-bigquery


【解决方案1】:

您可以使用以下简单方法

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     

有输出

【讨论】:

    猜你喜欢
    • 2016-04-03
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 2018-07-13
    • 2017-02-04
    • 1970-01-01
    相关资源
    最近更新 更多