Search notes:

Oracle SQL function: REGEXP_SUBSTR

regexp_substr is the regular expression variant of substr.
The basic usage of regexp_substr is to search for the regular expressions pattern in text and return the portion of text that matches this pattern:
regexp_substr ( text , pattern )
Optionally, a start position can be stated: the first character of text where a matching pattern should be after:
regexp_substr ( text , pattern , start_position )
In case that there are multiple portions in text that match pattern, an optional occurence can be give to return the n-th match:
regexp_substr ( text , pattern , start_position , occurence )
A match_param can be used to change the default function:
regexp_substr ( text , pattern , start_position , occurence, match_param)
Finally, an other optional parameter is sub_expression (a number between 1 and 9):
regexp_substr ( text , pattern , start_position , occurence, match_param , sub_expression)

Some basic examples

Extract a number from a string

select regexp_substr('foo3245bar', '\d+') from dual;
--
-- 2345

Extract third value from a semicolon separated string

create table tq84_regexp_substr (
   col_1  varchar2(30)
);

insert into tq84_regexp_substr values ('abc;def;ghi;klm');

-- Extract the third value
select       regexp_substr(col_1, '[^;]+[^;]', 1, 3)       third from tq84_regexp_substr;
--
-- ghi

--
-- Same thing with alternative regexp
select rtrim(regexp_substr(col_1, '.*?;'     , 1, 3), ';') third from tq84_regexp_substr;
--
-- ghi

drop table tq84_regexp_substr purge;

Extract the portion of a text between two delimiters

The following example extracts the portion of the text that is delimeted with > and <.
declare
  str  varchar2(100) := 'foo bar >words and such< baz';
begin
   dbms_output.put_line(regexp_substr(
      str    ,  -- Text
     '[^><]+',  -- Any repetation of characters that don't match the delimiters > and <
      1      ,  -- Start at first position
      2         -- Second occurence (The first is before >)
     )
   );
end;
/

Split text into records of words

This example uses the regular expression pattern \w+ in combination with a recursive query to extract «words» from a text. Each word is returned as a record:
select
   regexp_substr('
This regexp_replace example returns a
record for each word in this text', '\w+', 1, level) word
from
   dual connect by level <= 12 --<== needs to be adjused or result set to be filtered.
;
--
-- WORD                                                                    
-- ------------------------------------------------------------------------
-- This
-- regexp_replace
-- example
-- returns
-- a
-- record
-- for
-- each
-- word
-- in
-- this
-- text

See also

regexp_substr() can be used to translate CSV lines to individual columns, see here.
Oracle functions for regular expressions
ORA-12727: invalid back reference in regular expression
regexp_substr is defined in the SQL Standard as feature F844.

Index