【发布时间】:2020-02-15 23:35:30
【问题描述】:
这个:
select regexp_matches('test text user:testuser,anotheruser hashtag:peach,phone,milk site:youtube.com,twitter.com flair:????bobby????', '^.*?(?=\s+[^:\s]+:)|([^:\s]+):([^:\s]+)','gi');
只给我一个组匹配和一个 NULL 行:
regexp_matches
-----------------
{NULL,NULL}
{flair,????bobby????}
我在这里测试时效果很好:
https://regex101.com/r/AxsatL/3
我做错了什么?
【问题讨论】:
-
您做错了什么是假设所有正则表达式引擎都是相同的。它们是不是。使用将要运行的引擎测试并构建您的表达式。在这种情况下,Postgres;请参阅 Postgres Pattern Matching 文档。
标签: regex postgresql regex-group postgres-9.6