@ -1,5 +1,5 @@
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.137 2003/02/05 17:41:32 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.138 2003/02/06 20:25:31 tgl Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
@ -2665,10 +2665,24 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
due to their availability in programming languages such as Perl and Tcl.
due to their availability in programming languages such as Perl and Tcl.
<acronym>RE</acronym>s using these non-POSIX extensions are called
<acronym>RE</acronym>s using these non-POSIX extensions are called
<firstterm>advanced</> <acronym>RE</acronym>s or <acronym>ARE</>s
<firstterm>advanced</> <acronym>RE</acronym>s or <acronym>ARE</>s
in this documentation. We first describe the ERE/ARE flavor and then
in this documentation. AREs are almost an exact superset of EREs,
mention the restrictions of the BRE form.
but BREs have several notational incompatibilities (as well as being
much more limited).
We first describe the ARE and ERE forms, noting features that apply
only to AREs, and then describe how BREs differ.
</para>
</para>
<note>
<para>
The form of regular expressions accepted by <productname>PostgreSQL</>
can be chosen by setting the <varname>REGEX_FLAVOR</> run-time parameter
(described in the &cite-admin;). The usual setting is
<literal>advanced</>, but one might choose <literal>extended</> for
maximum backwards compatibility with pre-7.4 releases of
<productname>PostgreSQL</>.
</para>
</note>
<para>
<para>
A regular expression is defined as one or more
A regular expression is defined as one or more
<firstterm>branches</firstterm>, separated by
<firstterm>branches</firstterm>, separated by
@ -2784,7 +2798,7 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
meaning in <productname>PostgreSQL</> string literals.
meaning in <productname>PostgreSQL</> string literals.
To write a pattern constant that contains a backslash,
To write a pattern constant that contains a backslash,
you must write two backslashes in the query.
you must write two backslashes in the query.
</para>
</para>
</note>
</note>
<table id="posix-quantifiers-table">
<table id="posix-quantifiers-table">
@ -3392,11 +3406,11 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
</para>
</para>
<para>
<para>
Normally the flavor of RE being used is specifi ed by
Normally the flavor of RE being used is determin ed by
application-dependent means .
<varname>REGEX_FLAVOR</> .
However, this can be overridden by a <firstterm>director</>.
However, this can be overridden by a <firstterm>director</> prefix .
If an RE of any flavor begins with <literal>***:</>,
If an RE of any flavor begins with <literal>***:</>,
the rest of the RE is an ARE.
the rest of the RE is taken as an ARE.
If an RE of any flavor begins with <literal>***=</>,
If an RE of any flavor begins with <literal>***=</>,
the rest of the RE is taken to be a literal string,
the rest of the RE is taken to be a literal string,
with all characters considered ordinary characters.
with all characters considered ordinary characters.
@ -3407,8 +3421,8 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
a sequence <literal>(?</><replaceable>xyz</><literal>)</>
a sequence <literal>(?</><replaceable>xyz</><literal>)</>
(where <replaceable>xyz</> is one or more alphabetic characters)
(where <replaceable>xyz</> is one or more alphabetic characters)
specifies options affecting the rest of the RE.
specifies options affecting the rest of the RE.
These supplement, and can override,
These options override any previously determined options (including
any options specified externally .
both the RE flavor and case sensitivity) .
The available option letters are
The available option letters are
shown in <xref linkend="posix-embedded-options-table">.
shown in <xref linkend="posix-embedded-options-table">.
</para>
</para>
@ -3432,7 +3446,7 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
<row>
<row>
<entry> <literal>c</> </entry>
<entry> <literal>c</> </entry>
<entry> case-sensitive matching (usual default ) </entry>
<entry> case-sensitive matching (overrides operator type ) </entry>
</row>
</row>
<row>
<row>
@ -3443,7 +3457,7 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
<row>
<row>
<entry> <literal>i</> </entry>
<entry> <literal>i</> </entry>
<entry> case-insensitive matching (see
<entry> case-insensitive matching (see
<xref linkend="posix-matching-rules">) </entry>
<xref linkend="posix-matching-rules">) (overrides operator type) </entry>
</row>
</row>
<row>
<row>
@ -3471,12 +3485,12 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
<row>
<row>
<entry> <literal>s</> </entry>
<entry> <literal>s</> </entry>
<entry> non-newline-sensitive matching (usual default) </entry>
<entry> non-newline-sensitive matching (default) </entry>
</row>
</row>
<row>
<row>
<entry> <literal>t</> </entry>
<entry> <literal>t</> </entry>
<entry> tight syntax (usual default; see below) </entry>
<entry> tight syntax (default; see below) </entry>
</row>
</row>
<row>
<row>
@ -3696,7 +3710,7 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
</para>
</para>
<para>
<para>
Two significant incompatibilites exist between AREs and the ERE syntax
Two significant incompatibiliti es exist between AREs and the ERE syntax
recognized by pre-7.4 releases of <productname>PostgreSQL</>:
recognized by pre-7.4 releases of <productname>PostgreSQL</>:
<itemizedlist>
<itemizedlist>
@ -3717,6 +3731,10 @@ SUBSTRING('foobar' FROM 'o(.)b') <lineannotation>o</lineannotation>
</para>
</para>
</listitem>
</listitem>
</itemizedlist>
</itemizedlist>
While these differences are unlikely to create a problem for most
applications, you can avoid them if necessary by
setting <varname>REGEX_FLAVOR</> to <literal>extended</>.
</para>
</para>
</sect3>
</sect3>