Home Explore Blog CI



postgresql

95th chunk of `doc/src/sgml/func.sgml`
e4410b99a5e744a3e8f2b45ac0372ee62407fc759fb541940000000100000fb9
 treatment for a trailing newline,
    the addition of complemented bracket expressions to the things
    affected by newline-sensitive matching,
    the restrictions on parentheses and back references in lookahead/lookbehind
    constraints, and the longest/shortest-match (rather than first-match)
    matching semantics.
   </para>
   </sect3>

   <sect3 id="posix-basic-regexes">
    <title>Basic Regular Expressions</title>

   <para>
    BREs differ from EREs in several respects.
    In BREs, <literal>|</literal>, <literal>+</literal>, and <literal>?</literal>
    are ordinary characters and there is no equivalent
    for their functionality.
    The delimiters for bounds are
    <literal>\{</literal> and <literal>\}</literal>,
    with <literal>{</literal> and <literal>}</literal>
    by themselves ordinary characters.
    The parentheses for nested subexpressions are
    <literal>\(</literal> and <literal>\)</literal>,
    with <literal>(</literal> and <literal>)</literal> by themselves ordinary characters.
    <literal>^</literal> is an ordinary character except at the beginning of the
    RE or the beginning of a parenthesized subexpression,
    <literal>$</literal> is an ordinary character except at the end of the
    RE or the end of a parenthesized subexpression,
    and <literal>*</literal> is an ordinary character if it appears at the beginning
    of the RE or the beginning of a parenthesized subexpression
    (after a possible leading <literal>^</literal>).
    Finally, single-digit back references are available, and
    <literal>\&lt;</literal> and <literal>\&gt;</literal>
    are synonyms for
    <literal>[[:&lt;:]]</literal> and <literal>[[:&gt;:]]</literal>
    respectively; no other escapes are available in BREs.
   </para>
   </sect3>

<!-- end re_syntax.n man page -->

   <sect3 id="posix-vs-xquery">
   <title>Differences from SQL Standard and XQuery</title>

   <indexterm zone="posix-vs-xquery">
    <primary>LIKE_REGEX</primary>
   </indexterm>

   <indexterm zone="posix-vs-xquery">
    <primary>OCCURRENCES_REGEX</primary>
   </indexterm>

   <indexterm zone="posix-vs-xquery">
    <primary>POSITION_REGEX</primary>
   </indexterm>

   <indexterm zone="posix-vs-xquery">
    <primary>SUBSTRING_REGEX</primary>
   </indexterm>

   <indexterm zone="posix-vs-xquery">
    <primary>TRANSLATE_REGEX</primary>
   </indexterm>

   <indexterm zone="posix-vs-xquery">
    <primary>XQuery regular expressions</primary>
   </indexterm>

    <para>
     Since SQL:2008, the SQL standard includes regular expression operators
     and functions that performs pattern
     matching according to the XQuery regular expression
     standard:
     <itemizedlist>
      <listitem><para><literal>LIKE_REGEX</literal></para></listitem>
      <listitem><para><literal>OCCURRENCES_REGEX</literal></para></listitem>
      <listitem><para><literal>POSITION_REGEX</literal></para></listitem>
      <listitem><para><literal>SUBSTRING_REGEX</literal></para></listitem>
      <listitem><para><literal>TRANSLATE_REGEX</literal></para></listitem>
     </itemizedlist>
     <productname>PostgreSQL</productname> does not currently implement these
     operators and functions.  You can get approximately equivalent
     functionality in each case as shown in <xref
     linkend="functions-regexp-sql-table"/>.  (Various optional clauses on
     both sides have been omitted in this table.)
    </para>

    <table id="functions-regexp-sql-table">
     <title>Regular Expression Functions Equivalencies</title>

     <tgroup cols="2">
      <thead>
       <row>
        <entry>SQL standard</entry>
        <entry><productname>PostgreSQL</productname></entry>
       </row>
      </thead>

      <tbody>
       <row>
        <entry><literal><replaceable>string</replaceable> LIKE_REGEX <replaceable>pattern</replaceable></literal></entry>
        <entry><literal>regexp_like(<replaceable>string</replaceable>, <replaceable>pattern</replaceable>)</literal> or <literal><replaceable>string</replaceable>

Title: Basic Regular Expressions (BREs) and Differences from SQL Standard and XQuery
Summary
This section details the differences between Basic Regular Expressions (BREs) and Extended Regular Expressions (EREs). It specifies how characters like '|', '+', and '?' are treated in BREs, the use of '\{' and '\}' for bounds, and how parentheses and special characters like '^', '$', and '*' are handled. It also mentions the availability of single-digit back references and '\<' and '\>' escapes in BREs. The section then discusses the absence of SQL standard regular expression operators and functions (LIKE_REGEX, OCCURRENCES_REGEX, etc.) in PostgreSQL and suggests alternative PostgreSQL functions for similar functionality.