Re: [PATCHES] regexp_replace

Поиск
Список
Период
Сортировка
От a_ogawa
Тема Re: [PATCHES] regexp_replace
Дата
Msg-id PIEMIKOOMKNIJLLLBCBBKEACCIAA.a_ogawa@hi-ho.ne.jp
обсуждение исходный текст
Ответ на Re: [PATCHES] regexp_replace  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [PATCHES] regexp_replace  (David Fetter <david@fetter.org>)
Список pgsql-hackers
Bruce Momjian wrote:
> David Fetter wrote:
> > On Mon, Jun 06, 2005 at 12:02:18PM -0400, Bruce Momjian wrote:
> > >
> > > Patch removed because we already have this functionality.
> >
> > We don't yet have this functionality, as the patch allows for using
> > second and later regex matches "()" in the replacement pattern.
> >
> > The function is misnamed.  It should be called regex_replace_all() or
> > some such, as it violates the principle of least astonishment by
> > replacing all instances by default.  Every other regex replacement
> > defaults to "replace first," not "replace all."  Or maybe it should
> > take a bool for "replace all," or...?  Anyhow, it's worth a discussion
> > :)
>
> Does anyone want to argue that this additional functionality is
> significant and deserves its own function or an additional argument to
> the existing function?

Oracle10g has a similar functionality. The name is regexp_replace.
There is the following usages in this functionality.
- Format the ZIP code and the telephone number, etc.
   Example: select regexp_replace('1112223333', '(\\d{3})(\\d{3})(\\d{4})',
                                  '(\\1) \\2-\\3');
            result: (111) 222-3333
- Delete an unnecessary white space.
   Example: select regexp_replace('A     B     C', '\\s+', ' ');
            result: A B C

I think that the usage increases if "replace all" or "replace first" can be
specified to this function.

regards,

---
Atsushi Ogawa


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: unicode upper/lower functions
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: adding new pages bulky way