17,086
社区成员
发帖
与我相关
我的任务
分享
with t3 as (
select 'aaa,bbb,ccc,ddd,eee,fff' str from dual
union all
select 'ddd,qqq,12,3333,42687,opqe' str from dual)
第一种:
select rtrim(regexp_replace(str,'([^,]+,){3}(([^,]+,){2})([^,]+)','\2'),',')
from t3
第二种:
select regexp_replace(str,'([^,]+,){3}([^,]+,)([^,]+),([^,]+)','\2\3')
from t3
不明白的私聊我qq 212646490
with tt as (
select 'aaa,bbb,ccc,ddd,eee,fff' a from dual
union all
select 'ddd,qqq,12,3333,42687,opqe' from dual)
select regexp_substr(a,'[^,]+',3,4) from tt;
当然这个是正数。你要反数的话,可以先算出逗号的个数,然后用减法算出是第几个逗号