有找到空白的功能吗?

时间:2019-04-26 16:12:41

标签: oracle plsql

我需要一个函数,该函数可以在字符串中的plsql中查找空格,例如“嗨,世界,这是我的字符串”

1 个答案:

答案 0 :(得分:2)

一种选择是使用正则表达式,即REGEXP_INSTR。这是一个例子。 POS表示空格的位置。

SQL> with test (col) as
  2    (select 'Hi world, this is my string' from dual)
  3  select regexp_instr(col, ' ', 1, level) pos
  4  from test
  5  connect by level <= regexp_count(col, ' ');

       POS
----------
         3
        10
        15
        18
        21

SQL>

要验证结果:

Hi world, this is my string
  *      *    *  *  *
123456789012345678901234567
  3      10   15 18 21
相关问题