Reputation: 15372
How can I use regex in Postgres to replace a capture with an upper case version of itself.
regexp_replace(pf.description, '^(.)(.*)$', '\U\1\E\2', 'gi') as description
is giving me the string back with the literal values \U
and \E
.
Upvotes: 2
Views: 3848
Reputation: 656616
There is no built-in regex functionality in Postgres to convert to upper / lower case (that I'd know of).
I would use left()
and right()
instead:
SELECT upper(left('test_string', 1))
|| lower(right('test_string', -1));
Result:
Test_string
Postgres regular expression functionality in the manual.
Upvotes: 4