Presto: Add function to convert strings to title case.

Created on 25 Feb 2020  路  3Comments  路  Source: prestosql/presto

According to the Presto docs, there is not currently a function to convert a string to title case.

enhancement syntax-needs-review

Most helpful comment

Thats a good workaround. Imho it would be good to have an actual function initcap or so.

All 3 comments

The typical standard name of such a function is initcap(string) from what i can tell.

This can be done using regex_replace. There's an example in the documentation: https://prestosql.io/docs/current/functions/regexp.html

```sql
SELECT regexp_replace('new york', '(\w)(\w*)', x -> upper(x[1]) || lower(x[2]));
-- 'New York'

Thats a good workaround. Imho it would be good to have an actual function initcap or so.

Was this page helpful?
0 / 5 - 0 ratings