Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: regexp_substr occurrences problem
Vladimir M. Zakharychev schrieb:
> Maxim Demenko wrote:
>> PhilHibbs schrieb: >>> So what should I write to get DEF and GHI out of 'ABC|DEF|GHI|JKL', >>> assuming variable length and number of segments, e.g. >>> 'A|BC|DEF|GHIJ|KLMNO' should match 'BC', 'DEF', and 'GHIJ'? >>> >>> Phil Hibbs. >>> >> Not knowing much about your restrictions, for the case you requested >> simple '\|.+\|' will suffice. >> >> Best regards >> >> Maxim
I think, i see what you mean. However, in my understanding OP wanted the
leading and trailing pipes (at least, it would be the result of his very first examples, if regexp would behave as he thought). If leading and trailing pipes are not required, i would probably use something like select regexp_replace('ABC|DEF|GHI|JLK|MNO', '([^\|]*\|)(.*)(\|[^\|]*)','\2') from dual;
instead of regexp_substr. The problem with '[^\|]+' is , that changing the occurence, can be obtained any desired token from the string, but not all inner tokens together (of course, i may be wrong interpreting the OP).
Best regards
Maxim Received on Tue Sep 19 2006 - 16:27:02 CDT