sql - 需要用于 URL 检查的正则表达式?
问题描述
我需要一个 URL 字符串的正则表达式。
我的 URL 字符串敌人喜欢
https 冒号 // 字符串点字符串/字符串(中间不包含任何空格)
解决方案
下面是 BigQuery 标准 SQL 的示例
#standardSQL
WITH `project.dataset.table` AS (
SELECT 'check this link http://www.example.com/products?id=1&page=2' tweet UNION ALL
SELECT 'http://www.example.com/products?id=1&page=2 this link is awesome' tweet UNION ALL
SELECT 'the link http://www.example.com/products?id=1&page=2 is awesome' tweet
)
SELECT REGEXP_REPLACE(tweet, r"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+", '') clean_tweet
FROM `project.dataset.table`
结果
Row clean_tweet
1 check this link
2 this link is awesome
3 the link is awesome
推荐阅读
- dart - Flutter 医生在 macos 上崩溃了
- javascript - 如何修复'index.js:1446警告:无法在未安装的组件上调用setState(或forceUpdate)......“在ReactJS
- angular - Angular5:构建全名时进行空检查
- python - 如何在包含至少一个下划线和大写字母的字符串中查找单词
- json - 未找到数据中心协调架构
- mysql - 我可以在 sql 中使用递归来完成这个查询吗?
- azure-devops - 子和的 DAX 表达式
- python - 如何使用 OpenCV 理解 Python 中的头部姿势估计角度?
- file - 使用 cmake 更改现有文件的权限
- kubernetes - 来自 StatefulSet 的 Pod 卡在 ContainerCreating 状态 - FailedCreatePodSandBox