pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedIs there an easy way to normalize-space with given string functions
3+ messages / 2 participants
[nested] [flat]
* Is there an easy way to normalize-space with given string functions
@ 2004-04-22 22:59 Janning Vygen <vygen@gmx.de>
2004-04-23 02:34 ` Re: Is there an easy way to normalize-space with given string functions Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Janning Vygen @ 2004-04-22 22:59 UTC (permalink / raw)
To: pgsql-sql
Hi,
i am looking for something like
$ SELECT btrim(replace(' too many spaces! ', '\s+',' '), '');
too many spaces
i searched the function list and tried to combine to or more functions, but i
miss a replace function which uses regular expressions.
Do i have to write my own function or did i miss something? trimming is well
supported at the start and end of string, but no trimmin in the middle seems
to be possible.
kind regards
janning
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is there an easy way to normalize-space with given string functions
2004-04-22 22:59 Is there an easy way to normalize-space with given string functions Janning Vygen <vygen@gmx.de>
@ 2004-04-23 02:34 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-04-23 09:37 ` Re: Is there an easy way to normalize-space with given string functions Janning Vygen <vygen@gmx.de>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2004-04-23 02:34 UTC (permalink / raw)
To: Janning Vygen <vygen@gmx.de>; +Cc: pgsql-sql
Janning Vygen <vygen@gmx.de> writes:
> i searched the function list and tried to combine to or more
> functions, but i miss a replace function which uses regular
> expressions.
There isn't one in the SQL standard. Most people who need one write a
one-liner function in plperl or pltcl.
(Mind you, I don't know why we don't offer a built-in one --- the needed
regex engine is in there anyway. I guess no one has gotten around to
getting agreement on a syntax.)
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is there an easy way to normalize-space with given string functions
2004-04-22 22:59 Is there an easy way to normalize-space with given string functions Janning Vygen <vygen@gmx.de>
2004-04-23 02:34 ` Re: Is there an easy way to normalize-space with given string functions Tom Lane <tgl@sss.pgh.pa.us>
@ 2004-04-23 09:37 ` Janning Vygen <vygen@gmx.de>
0 siblings, 0 replies; 3+ messages in thread
From: Janning Vygen @ 2004-04-23 09:37 UTC (permalink / raw)
To: pgsql-sql
Am Freitag, 23. April 2004 04:34 schrieb Tom Lane:
> Janning Vygen <vygen@gmx.de> writes:
> > i searched the function list and tried to combine to or more
> > functions, but i miss a replace function which uses regular
> > expressions.
>
> There isn't one in the SQL standard. Most people who need one write a
> one-liner function in plperl or pltcl.
Thank you.
> (Mind you, I don't know why we don't offer a built-in one --- the needed
> regex engine is in there anyway. I guess no one has gotten around to
> getting agreement on a syntax.)
My suggestion:
Syntax:
substitute(string text, from text, to text);
Example:
substitute(' too many spaces ', '\s+', ' ');
Result:
' too many spaces '
But maybe its a bad idea to create new function names...
kind regards
janning
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2004-04-23 09:37 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-22 22:59 Is there an easy way to normalize-space with given string functions Janning Vygen <vygen@gmx.de>
2004-04-23 02:34 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-04-23 09:37 ` Janning Vygen <vygen@gmx.de>
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