Ok, given these assumptions:
- Your sample data is 3 lines
- The entire line is in one column
- You don't want the
*.*
in the first line
Try this:
SQL> with tbl(line_nbr, str) as (
select 1, 'All Files (*.*)|*.*|Bitmap (*.bmp)|*.bmp|Microsoft Word Document' from dual
union
select 2, '(*.docx)|*.docx|GIF (*.gif)|*.gif|JPEG (*.jpg)|*.jpg|PNG' from dual
union
select 3, '(*.png)|*.png|Adobe Reader (*.pdf)|*.pdf|TIFF (*.tif)|*.tif' from dual
)
SELECT line_nbr, str,
COLUMN_VALUE AS match_nbr,
REGEXP_SUBSTR( str ,'\(\*\.(\w*)\)', 1, COLUMN_VALUE, NULL, 1 ) AS match_value
FROM tbl,
TABLE(
CAST(
MULTISET(
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT( str ,'\(\*\.\w*\)' )
) AS SYS.ODCINUMBERLIST
)
);
LINE_NBR STR MATCH_NBR MATCH_VALUE
---------- ---------------------------------------------------------------- ---------- -----------
1 All Files (*.*)|*.*|Bitmap (*.bmp)|*.bmp|Microsoft Word Document 1 bmp
2 (*.docx)|*.docx|GIF (*.gif)|*.gif|JPEG (*.jpg)|*.jpg|PNG 1 docx
2 (*.docx)|*.docx|GIF (*.gif)|*.gif|JPEG (*.jpg)|*.jpg|PNG 2 gif
2 (*.docx)|*.docx|GIF (*.gif)|*.gif|JPEG (*.jpg)|*.jpg|PNG 3 jpg
3 (*.png)|*.png|Adobe Reader (*.pdf)|*.pdf|TIFF (*.tif)|*.tif 1 png
3 (*.png)|*.png|Adobe Reader (*.pdf)|*.pdf|TIFF (*.tif)|*.tif 2 pdf
3 (*.png)|*.png|Adobe Reader (*.pdf)|*.pdf|TIFF (*.tif)|*.tif 3 tif
7 rows selected.
SQL>
Thanks to MT0 in this post for the trick to properly handle mutiple rows: Split string by space and character as delimiter in Oracle with regexp_substr