Oracle REGEXP_SUBSTR 当有多个空格时按空格提取字符串
Oracle REGEXP_SUBSTR extracts strings by blank when there are multiple blanks
您好,我是 Oracle SQL 的新手,我想从 6Cell LiIon Polymer
中提取 LiIon Polymer
。
我使用 REGEXP_SUBSTR('6Cell LiIon Polymer', '\S+', 7)
但它只 returns LiIon
您想要第一个 space 之后的子字符串吗?使用好,旧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>
使用正则表达式且不进行硬编码
select REGEXP_SUBSTR('6Cell LiIon Polymer', '[^\S]+', instr('6Cell LiIon Polymer', ' '), 1) from dual;
您好,我是 Oracle SQL 的新手,我想从 6Cell LiIon Polymer
中提取 LiIon Polymer
。
我使用 REGEXP_SUBSTR('6Cell LiIon Polymer', '\S+', 7)
但它只 returns LiIon
您想要第一个 space 之后的子字符串吗?使用好,旧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>
使用正则表达式且不进行硬编码
select REGEXP_SUBSTR('6Cell LiIon Polymer', '[^\S]+', instr('6Cell LiIon Polymer', ' '), 1) from dual;