How to get these data I want in Oracle, using REGEXP_SUBSTR
SPRINTMVNO_PM_CDR_IWIRELESS_20121110_0813.csv get '08'in last four digits
RK_IPDR_RKMSG2_0043722_DT_20121113162710.txt get '0043722' in the middle(between'_')
wireless_201211120015_201211120515 get '0515' (last four digits)
I have tried many times, but some expression works fine in PHP or other language but not work in ORACLE. Maybe the syntax is different.
For example : the second one I can use /(?<=_)[0-9]*(?=_)/ to get the number in php, but this does not work in Oracle.
I tried
SELECT REGEXP_SUBSTR('RK_IPDR_RKMSG2_0043722_DT_20121113162710.txt','(?<=_)[0-9]*(?=_)')
FROM dual;
No output. So it's not the problem of the two slash lines
An alternate formulation of this question would be "how to get content between or start with a character but not include it, with Oracle's regex ? "
I know I can get those data easily by using string functions, the problem is there are tons of different strings to handle, each of them have different data to retrieve. So I want to store the patterns into database, and use one regexp_substr to get all data. Otherwise I need to hard code those rules.