如果您使用11g,则可以使用regexp_count来确定字符串中存在模式的次数并将其提供给regexp_instr
regexp_instr( str,'[[:digit:]]',1,regexp_count( str,'[[:digit:]]')
)
但是,由于你是10g,最简单的选择可能是反转字符串并减去从字符串长度中找到的位置
length(str) - regexp_instr(reverse(str),'[[:digit:]]') + 1
两种方法都应该在11g
sql> ed
Wrote file afiedt.buf
1 with x as (
2 select '500 Oracle Parkway,CA' str
3 from dual
4 )
5 select length(str) - regexp_instr(reverse(str),'[[:digit:]]') + 1,6 regexp_instr( str,7 '[[:digit:]]',8 1,9 regexp_count( str,'[[:digit:]]')
10 )
11* from x
sql> /
LENGTH(STR)-REGEXP_INSTR(REVERSE(STR),'[[:DIGIT:]]')+1
------------------------------------------------------
REGEXP_INSTR(STR,'[[:DIGIT:]]',REGEXP_COUNT(STR,'[[:DIGIT:]]'))
-----------------------------------------------------------------
3
3