David Fetter wrote: > On Tue, Jun 07, 2005 at 10:27:28PM +0900, Atsushi Ogawa wrote: > > David Fetter wrote: > > > Ogawa-san, > > > > > > I think that this would be a case for function overloading: > > > > > > function regexp_replace( > > > string text, pattern text, replacement text > > > ) RETURNS TEXT; /* First only */ > > > > > > regexp_replace( > > > string text, pattern text, replacement text, global bool > > > ) RETURNS TEXT; /* Global if global is TRUE, first only otherwise */ > > > > > > What do you think of this idea? One trouble is that there are some > > > other options. For example, one could add switches for all > > > combinations of "global," "case insensitive," "compile once," "exclude > > > whitespace," etc. as perl does. Do we want to go this route? > > > > My idea is opposite. I think that the regexp_replace() should make > > "replace all" a default. Because the replace() of pgsql replaces all > > string, and regexp_replace() of oracle10g is also similar. > > I respectfully disagree. Although Oracle does things this way, no > other regular expression search and replace does. Historically, you > can find that "Oracle does it this way" is not a reason why we would > do it. Text editors, programming languages, etc., etc. do "replace > the first" by default and "replace globally" only when told to.
I agree. Let's stop the way to Oracle. > > And I think that it is better to be able to specify the option with text. > > I think that "case insensitive" is a good thing to add separately as a > boolean :) I don't like to specify operation with boolean. ;) Because when a SQL is read, the meaning becomes indistinct. How about changing the function name of each usage? regexp_replace: replace first regexp_replace_all: replace all regexp_ic_replace: replace first and case insensitive regexp_ic_replace_all: replace all and case insensitive regards, -- Atsushi Ogawa ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org