regex - Need Help Rewriting Regex with only 1 Capturing Group
问题描述
The below regex extracts what I need but I am getting this error in BigQuery:
"Regular expression passed to REGEXP_EXTRACT_ALL must not have more than 1 capturing group"
I tried to get rid of the 2nd capturing group but can't figure out how to get the same results. Expect the results to be:
["split.attribute1": "off","split.attribute2": "20off","split.attribute3": "excluded"]
Regex:
(?:"split(.*?)": ")(.*?)(?:")
Sample Data:
{"split.attribute1": "off", "hostname": "www.test.com", "split.attribute2": "20off", "split.attribute3": "excluded"}
解决方案
以下是 Bigquery 标准 SQL
#standardSQL
SELECT REGEXP_EXTRACT_ALL(data, r'("split..*?)(?:,|})') attributes
FROM `project.dataset.table`
如果适用于您问题中的示例行 - 输出是
Row attributes
1 "split.attribute1": "off"
"split.attribute2": "20off"
"split.attribute3": "excluded"
推荐阅读
- android - 什么是应用程序的扩展?
- iccube - IcCube 将自定义属性添加到数据源表?
- node.js - 如何在 Node 应用程序中使用 `mongo DB` 数据进行分析
- android - 覆盖 onActivityResult 使构建失败
- python - 如何使用python脚本获取apache的home body数据?
- mysql - MySQL从服务器不执行删除用户命令
- php - 错误:无效的路径表达式。必须是字段选择失败的 StateFieldPathExpression
- javascript - 合并后表格中的 GAS 脚本更改日期和时间
- excel - 将组合框连接到 VBA
- c# - 如何调整此 LINQ 查询以避免 SORT 但仍检索 IEnumerable?