pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Feature request for INITCAP() function
3+ messages / 3 participants
[nested] [flat]

* Feature request for INITCAP() function
@ 2023-12-01 02:08  Jeff Gerbracht <jeffgerbracht@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Jeff Gerbracht @ 2023-12-01 02:08 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

It would be great if there was a way to set exceptions to the 'word'
delimiter list used in the INITCAP() function.    For example, I have
hyphenated words like blue-green or possessives and contractions like don't
and cat's tail
These become Blue-Green, Don'T and Cat'S Tail.

Being able to pass in a set of delimiter exceptions like hyphen and single
quote would make this function much more useful for our specific use cases.

   Thanks for considering,
      Jeff
-- 
Jeff Gerbracht
Cornell Lab of Ornithology

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Feature request for INITCAP() function
@ 2023-12-01 07:22  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Jeff Gerbracht <jeffgerbracht@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Laurenz Albe @ 2023-12-01 07:22 UTC (permalink / raw)
  To: Jeff Gerbracht <jeffgerbracht@gmail.com>; pgsql-general@lists.postgresql.org

On Thu, 2023-11-30 at 21:08 -0500, Jeff Gerbracht wrote:
> It would be great if there was a way to set exceptions to the 'word' delimiter list used in
> the INITCAP() function.    For example, I have hyphenated words like blue-green or
> possessives and contractions like don't and cat's tail
> These become Blue-Green, Don'T and Cat'S Tail.
> 
> Being able to pass in a set of delimiter exceptions like hyphen and single quote would make
> this function much more useful for our specific use cases.

That would pretty quickly drift into locale-dependent rules.  Such a function would be even
more special-case than the current "initcap()", which is already pretty specific to certain
languages.  I don't know if there is enough value for the general public in it.

But it should be easy to implement it yourself, for example in PL/pgSQL.  Why don't you
try that?

Yours,
Laurenz Albe





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Feature request for INITCAP() function
@ 2023-12-01 11:52  Daniel Verite <daniel@manitou-mail.org>
  parent: Jeff Gerbracht <jeffgerbracht@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Daniel Verite @ 2023-12-01 11:52 UTC (permalink / raw)
  To: Jeff Gerbracht <jeffgerbracht@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

	Jeff Gerbracht wrote:

> It would be great if there was a way to set exceptions to the 'word'
> delimiter list used in the INITCAP() function.    For example, I have
> hyphenated words like blue-green or possessives and contractions like
> don't and cat's tail
> These become Blue-Green, Don'T and Cat'S Tail.

An ICU collation may produce better results for this:
 
select initcap('blue-green don''t cat''s tail' COLLATE "en-x-icu");
	   initcap	     
-----------------------------
 Blue-Green Don't Cat's Tail

With hyphens, it's not clear what the results should be.
Looking at the IMDb movies database [1] for instance, titles have
a mix of upper and lower case following the hyphen, even within the
same english title:

Hell-to-Pay Austin
The Co-respondent
A Pit-boy's Romance
A Cowboy's Mother-in-Law
Our Parents-In-Law
The Good-for-Nothing
When the Fire-Bells Rang
The post-millennial wave
...

[1] https://datasets.imdbws.com/


Best regards,
-- 
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2023-12-01 11:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01 02:08 Feature request for INITCAP() function Jeff Gerbracht <jeffgerbracht@gmail.com>
2023-12-01 07:22 ` Laurenz Albe <laurenz.albe@cybertec.at>
2023-12-01 11:52 ` Daniel Verite <daniel@manitou-mail.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox