Is there a way to convert a string to ‘Proper’ casing? I’m using the Excel definition of ‘Proper’ which will format text such that the first letter of any word is capitalized and the remaining letters are lower case.
Sample Inputs | Outputs
I browsed the string function/operators Presto documentation so it seems like this isn’t possible, but hoping someone here can prove me wrong!
Advertisement
Answer
You use regexp_replace
to turn string into the title case:
select regexp_replace('Hell asdasd QWEEQ aWQW', '(w)(w*)', x -> upper(x[1]) || lower(x[2]));
Output:
_col0 |
---|
Hell Asdasd Qweeq Awqw |