且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以声明方式从Postgres字符串中获取最后一个单词

更新时间:2023-08-25 22:17:58

如果我正确地理解了您的问题,则您有一个字符串,首先要在某个分隔符上将其拆分,然后再查找

If I understand your question correctly you have a string and you're first splitting it on some separator and then afterwards finding the last element of the array and discarding the rest.

您可能会错过中间人并直接获得最后一个元素:

You could miss out the middle man and get the last element directly:

SELECT regexp_replace('foo bar baz', '^.* ', '')

结果:

baz