Re: Using regexp_replace to remove small words

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vick Khera <vivek(at)khera(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using regexp_replace to remove small words
Date: 2010-12-13 15:00:34
Message-ID: 7222.1292252434@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vick Khera <vivek(at)khera(dot)org> writes:
> speaking of regular expressions... the other day I was trying to find
> where the 'flags' option to regexp_replace() is described, but I
> cannot find it in the 9.0 manual in any obvious place. it is not
> described in the string functions section, nor in the regexp section.

It's described in the same paragraph that describes regexp_replace, in
http://www.postgresql.org/docs/9.0/static/functions-matching.html

The regexp_replace function provides substitution of new text for
substrings that match POSIX regular expression patterns. It has the
syntax regexp_replace(source, pattern, replacement [, flags ]). The
source string is returned unchanged if there is no match to the
pattern. If there is a match, the source string is returned with the
replacement string substituted for the matching substring. The
replacement string can contain \n, where n is 1 through 9, to
indicate that the source substring matching the n'th parenthesized
subexpression of the pattern should be inserted, and it can contain
\& to indicate that the substring matching the entire pattern should
be inserted. Write \\ if you need to put a literal backslash in the
replacement text. (As always, remember to double backslashes written
in literal constant strings, assuming escape string syntax is used.)
The flags parameter is an optional text string containing zero or
more single-letter flags that change the function's behavior. Flag i
specifies case-insensitive matching, while flag g specifies
replacement of each matching substring rather than only the first
one. Other supported flags are described in Table 9-19.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Gravsjö 2010-12-13 15:04:26 Re: RES: Using regexp_replace to remove small words
Previous Message paulo matadr 2010-12-13 15:00:23 Cluster with LATIN1 and UTF-8