I'm trying to split a string using a string as a delimiter, in an Oracle store procedure. I can use instr
easily, but I'm trying to learn how to do this with regex, as I understand that it is powerful and efficient.
After reading some articles, I thought I could do this (expected result was "Hello
"):
select regexp_substr('Hello My Delimiter World', '( My Delimiter )+', 1, 1)
from dual
Result:
My Delimiter
and (expected result was "World
"):
select regexp_substr('Hello My Delimiter World', '( My Delimiter )+', 1, 2)
from dual
Result:
null
What is the correct regex_substr for this requirement?
EDIT: I'm looking for something like the below. In a single pass, it selects the sub-string within the string:
E.g. select regexp_substr('Hello World', '[^ ]+', 1, 2) from dual
But this sample only works with a single character.