I have a column in our database that holds 4 fields as a \"\\\" delimited string.
I have split the fields as I need them seperatly in my report.
I also need to
WARNING! The regular expression '[^\]+'
will return unexpected results if there is a null item in the list and you are selecting the element after that null item. See this example where the 3rd item is selected, but '4' is returned. '4' is really the 4th item in the delimited list, not the third. Indeed it is the 3rd item where there is a value though.
SQL> select REGEXP_SUBSTR('1\\3\4', '[^\]+', 1, 3) colA from dual;
C
-
4
SQL>
Use this instead, where the actual 3rd item in the list is selected:
SQL> select REGEXP_SUBSTR('1\\3\4', '([^\]*)(\\|$)', 1, 3, NULL, 1) colA from dual;
C
-
3
See this post for a more detailed example and explanation: REGEX to select nth value from a list, allowing for nulls