首页 > 解决方案 > Oracle regexp_substr 提取数据 - 2

问题描述

旧问题 ID = 62489141

我添加了另一个输入文本。

我正在尝试从字符串中提取下载和上传速度数,无法实现,请帮助。

下面的字符串存在于表的一列中

输入字符串:

My ADSL 2M(200) Volume 14Mbps/2M speed threshold 0M

我需要出的SQL应该是

download_speed upload_spped
14             2

如果没有其他数字,则以前建议的 SQL 提取数据正确提供。

标签: sqlregexoracle

解决方案


您可以regexp_substr按如下方式使用:

with d (str) as
(select 'My ADSL 2M(200) Volume 14Mbps/2M speed threshold 0M'
 from dual)
 -- your query starts from here.
select regexp_substr(spd, '[0-9]+',1,1) as download_speed,
regexp_substr(spd, '[0-9]+',1,2) as upload_speed
from
 (select regexp_substr(str, '[0-9]+M[a-z|A-Z]+/[0-9]+[a-z|A-Z]+') as spd
    from d)

推荐阅读