gpt4 book ai didi

regex - Postgres 正则表达式为大写

转载 作者:行者123 更新时间:2023-11-29 12:05:24 26 4
gpt4 key购买 nike

如何在 Postgres 中使用正则表达式将捕获替换为自身的大写版本。

regexp_replace(pf.description, '^(.)(.*)$', '\U\1\E\2', 'gi') as description

返回给我字符串值 \U\E

最佳答案

Postgres 中没有内置的正则表达式功能来转换为大写/小写(据我所知)。

我会使用 left() and right()相反:

SELECT upper(left('test_string', 1))
|| lower(right('test_string', -1));

结果:

Test_string

Postgres regular expression functionality in the manual.

关于regex - Postgres 正则表达式为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497666/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com