Your regular expression is wrong and will not match "results from a column string which is between >
and <\
" as it never matches an initial >
.
If you want to match between those then you need to include the leading >
and then you can just match as few characters as possible (using the non-greedy pattern [^<>]*?
) until you find </
(in the description you state \
and in the code you use /
. I assume you want /
as that is used in XML):
SELECT REGEXP_SUBSTR (
'Column',
'>([^<>]*?)</',
1,
1,
NULL,
1
)
FROM table_name
As for:
what is ([^>]+)\</
, Null
(5th) and 1
(6th)
The regular expression is incorrect as it will match one-or-more non->
characters until it finds the first </
sub-string.
The parameters are described in Oracle's REGEXP_SUBSTR
documentation and are the match_param
and subexp
arguments. A complete description is available in the documentation but your arguments will use the default match parameters and return the contents of the first capturing group.
However
If you are really parsing XML (or XHTML) then you would be better using a proper XML parser such as XMLTABLE
.