与Postgres regexp_matches多次匹配

And*_*huk 11 regex postgresql

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

regexp_matches("Hello #world #planet", '#([A-Za-z0-9]+)')
Run Code Online (Sandbox Code Playgroud)

干杯,安德烈

Luk*_*zda 10

你应该附上字符串字面与'".添加'g'评论中的建议应该有助于:

SELECT regexp_matches('Hello #world #planet', '#([A-Za-z0-9]+)', 'g')
Run Code Online (Sandbox Code Playgroud)

SqlFiddleDemo

??????????????????
? regexp_matches ?
??????????????????
? world          ?
? planet         ?
??????????????????
Run Code Online (Sandbox Code Playgroud)