Home Explore Blog CI



postgresql

39th chunk of `doc/src/sgml/func.sgml`
97d3aed0a644b819d6b0574a0efb7a48c3190d17d98cf0bb0000000100000fb2
 <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>
         <optional>, <parameter>start</parameter> <type>integer</type>
         <optional>, <parameter>flags</parameter> <type>text</type> </optional> </optional> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Returns the number of times the POSIX regular
        expression <parameter>pattern</parameter> matches in
        the <parameter>string</parameter>; see
        <xref linkend="functions-posix-regexp"/>.
       </para>
       <para>
        <literal>regexp_count('123456789012', '\d\d\d', 2)</literal>
        <returnvalue>3</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>regexp_instr</primary>
        </indexterm>
        <function>regexp_instr</function> ( <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>
         <optional>, <parameter>start</parameter> <type>integer</type>
         <optional>, <parameter>N</parameter> <type>integer</type>
         <optional>, <parameter>endoption</parameter> <type>integer</type>
         <optional>, <parameter>flags</parameter> <type>text</type>
         <optional>, <parameter>subexpr</parameter> <type>integer</type> </optional> </optional> </optional> </optional> </optional> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Returns the position within <parameter>string</parameter> where
        the <parameter>N</parameter>'th match of the POSIX regular
        expression <parameter>pattern</parameter> occurs, or zero if there is
        no such match; see <xref linkend="functions-posix-regexp"/>.
       </para>
       <para>
        <literal>regexp_instr('ABCDEF', 'c(.)(..)', 1, 1, 0, 'i')</literal>
        <returnvalue>3</returnvalue>
       </para>
       <para>
        <literal>regexp_instr('ABCDEF', 'c(.)(..)', 1, 1, 0, 'i', 2)</literal>
        <returnvalue>5</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>regexp_like</primary>
        </indexterm>
        <function>regexp_like</function> ( <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>
         <optional>, <parameter>flags</parameter> <type>text</type> </optional> )
        <returnvalue>boolean</returnvalue>
       </para>
       <para>
        Checks whether a match of the POSIX regular
        expression <parameter>pattern</parameter> occurs
        within <parameter>string</parameter>; see
        <xref linkend="functions-posix-regexp"/>.
       </para>
       <para>
        <literal>regexp_like('Hello World', 'world$', 'i')</literal>
        <returnvalue>t</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>regexp_match</primary>
        </indexterm>
        <function>regexp_match</function> ( <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type> <optional>, <parameter>flags</parameter> <type>text</type> </optional> )
        <returnvalue>text[]</returnvalue>
       </para>
       <para>
        Returns substrings within the first match of the POSIX regular
        expression <parameter>pattern</parameter> to
        the <parameter>string</parameter>; see
        <xref linkend="functions-posix-regexp"/>.
       </para>
       <para>
        <literal>regexp_match('foobarbequebaz', '(bar)(beque)')</literal>
        <returnvalue>{bar,beque}</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>regexp_matches</primary>
        </indexterm>
        <function>regexp_matches</function>

Title: PostgreSQL String Functions: REGEXP_INSTR, REGEXP_LIKE, REGEXP_MATCH
Summary
This section describes more PostgreSQL string functions related to regular expressions: `regexp_instr` (finds the position of a regular expression match), `regexp_like` (checks for a regular expression match), and `regexp_match` (returns substrings of the first match).