我的数据可能如下所示
Goods Receipt required for document 5105250265 from Vendor
Goods Receipt(s) have been fully taken for document 5105295587
Goods Receipt required for document 5105285525 from Vendor
Please process Vendor invoice from CARDIFF COUNTY COUNC, reference 1801314625
Goods Receipt required for document 5105302265 from Vendor
我要提取的数字以5开头,总是10位数。
提取此数字的最佳方式是什么?
最好的可能是
select regexp_replace(column, '[A-Za-z]') from table
但是这不会检查数字是以5开头还是10位数
答案 0 :(得分:2)
假设您最多只有一个数字符合您的条件,您可以尝试以下方法:
with test (text) as
(
select 'Goods Receipt required for document 5105250265 from Vendor' from dual union all
select 'Goods Receipt(s) have been fully taken for document 5105295587' from dual union all
select 'Goods Receipt required for document 5105285525 from Vendor' from dual union all
select 'Please process Vendor invoice from CARDIFF COUNTY COUNC, reference 1801314625' from dual union all
select 'Goods Receipt required for document 5105302265 from Vendor' from dual
)
select regexp_substr(text, '5[0-9]{9}')
from test