我试图使用Postgres regexp_matches函数从字符串中提取主题标签...以下示例仅返回一个匹配项-如何提取两个主题标签?

regexp_matches("Hello #world #planet", '#([A-Za-z0-9]+)')

干杯,
安德烈

最佳答案

您应该用'而不是"括住字符串文字。按照注释中的建议添加'g'应该会有所帮助:

SELECT regexp_matches('Hello #world #planet', '#([A-Za-z0-9]+)', 'g')

SqlFiddleDemo
╔════════════════╗
║ regexp_matches ║
╠════════════════╣
║ world          ║
║ planet         ║
╚════════════════╝

关于regex - 使用Postgres regexp_matches进行多次匹配,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36537834/

10-11 03:16