首页 > 解决方案 > Oracle REGEXP_SUBSTR 在有多个空格时按空格提取字符串

问题描述

您好我是 Oracle SQL 的新手,我想LiIon Polymer6Cell LiIon Polymer.

我使用REGEXP_SUBSTR('6Cell LiIon Polymer', '\S+', 7)但它只返回LiIon

标签: oracleregexp-substr

解决方案


您想要第一个空格后面的子字符串吗?使用好的,旧的 substr+instr组合。首先是样本数据,您可能感兴趣的查询从第 4 行开始。

SQL> with test (col) as
  2    (select '6Cell LiIon Polymer' from dual)
  3  --
  4  select substr(col, instr(col, ' ') + 1) result
  5  from test;

RESULT
-------------
LiIon Polymer

SQL>

推荐阅读