regex - 如何使用正则表达式替换 Google Data Studio 中日期字段的方括号?
问题描述
我正在尝试删除 Google Data Studio 中日期字段周围的方括号,以便我可以正确地将其视为正确的日期维度。
它看起来像这样:
[2020-05-20 00:00:23]
我正在使用 RegExREGEXP_REPLACE(Date, "/[\[\]']+/g", "")
并且我希望它的输出看起来像这样:
2020-05-20 00:00:23
它不断给我错误结果并且不起作用。我无法弄清楚我在这里做错了什么,我已经使用https://www.regextester.com/来验证它是否应该工作
解决方案
You need to use a plain regex pattern, not a regex literal notation (/.../g
).
Note that REGEXP_REPLACE
removes all occurrences found, thus, there is no need for a g
flag.
Use
REGEXP_REPLACE(Date, "[][]+", "")
to remove all square brackets in Date
.
推荐阅读
- javascript - 从 Firestore 中检索文档字段值
- python - 如何为 postgresql 中的唯一(不包括顺序)JSONB 列创建约束
- javascript - “未捕获的类型错误:无法读取未定义的属性 ''”但仍显示在警报和 console.log 上
- swiperjs - Swiper JS Slides 显示 5,但只有活动类更改而不是滑块
- vue.js - 通过 Nginx 反向代理通信,使用 websockets 到达 NestJS 网关
- sql - 在 SQL 中提取 JSON 变量中的嵌套数据
- asp.net-mvc - 将超大型 ASP.NET MVC 5.2 SaaS 应用程序迁移到 ASP.NET MVC Core 的提示
- javascript - 如何在 REACT 中将唯一 ID 传递给多个 Datepicker?
- applescript - 我正在寻找一个文件夹识别保存到其中的新文件,然后将新文件复制到一个整理的文件夹中
- python - 如何将列表值添加到特定列