<bdo id='3bITS'></bdo><ul id='3bITS'></ul>

<small id='3bITS'></small><noframes id='3bITS'>

  1. <i id='3bITS'><tr id='3bITS'><dt id='3bITS'><q id='3bITS'><span id='3bITS'><b id='3bITS'><form id='3bITS'><ins id='3bITS'></ins><ul id='3bITS'></ul><sub id='3bITS'></sub></form><legend id='3bITS'></legend><bdo id='3bITS'><pre id='3bITS'><center id='3bITS'></center></pre></bdo></b><th id='3bITS'></th></span></q></dt></tr></i><div id='3bITS'><tfoot id='3bITS'></tfoot><dl id='3bITS'><fieldset id='3bITS'></fieldset></dl></div>
  2. <legend id='3bITS'><style id='3bITS'><dir id='3bITS'><q id='3bITS'></q></dir></style></legend>
    <tfoot id='3bITS'></tfoot>

      regexp_substr 跳过空位置

      regexp_substr skips over empty positions(regexp_substr 跳过空位置)

        <i id='qGZnI'><tr id='qGZnI'><dt id='qGZnI'><q id='qGZnI'><span id='qGZnI'><b id='qGZnI'><form id='qGZnI'><ins id='qGZnI'></ins><ul id='qGZnI'></ul><sub id='qGZnI'></sub></form><legend id='qGZnI'></legend><bdo id='qGZnI'><pre id='qGZnI'><center id='qGZnI'></center></pre></bdo></b><th id='qGZnI'></th></span></q></dt></tr></i><div id='qGZnI'><tfoot id='qGZnI'></tfoot><dl id='qGZnI'><fieldset id='qGZnI'></fieldset></dl></div>
          <bdo id='qGZnI'></bdo><ul id='qGZnI'></ul>
          <tfoot id='qGZnI'></tfoot>

            <small id='qGZnI'></small><noframes id='qGZnI'>

                <legend id='qGZnI'><style id='qGZnI'><dir id='qGZnI'><q id='qGZnI'></q></dir></style></legend>

                  <tbody id='qGZnI'></tbody>
              • 本文介绍了regexp_substr 跳过空位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                使用此代码返回管道分隔字符串中的第 n 个值...

                With this code to return the nth value in a pipe delimited string...

                regexp_substr(int_record.interfaceline, '[^|]+', 1, i)
                

                当所有值都存在时它工作正常

                it works fine when all values are present

                Mike|Male|Yes|20000|Yes 所以 3rd 值为 Yes(正确)

                Mike|Male|Yes|20000|Yes so the 3rd value is Yes (correct)

                但是如果字符串是

                Mike|Male||20000|Yes,第三个值是20000(不是我想要的)

                Mike|Male||20000|Yes, the 3rd value is 20000 (not what I want)

                如何告诉表达式不要跳过空值?

                How can I tell the expression to not skip over the empty values?

                TIA

                迈克

                推荐答案

                好的.这应该是最适合您的解决方案.

                OK. This should be the best solution for you.

                SELECT
                      REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                    '^([^|]*|){2}([^|]*).*$',
                                    '2' )
                          TEXT
                FROM
                      DUAL;
                

                所以对于你的问题

                SELECT
                      REGEXP_REPLACE ( INCOMINGSTREAMOFSTRINGS,
                                    '^([^|]*|){N-1}([^|]*).*$',
                                    '2' )
                          TEXT
                FROM
                      DUAL;
                

                --INCOMINGSTREAMOFSTRINGS 是带分隔符的完整字符串

                --INCOMINGSTREAMOFSTRINGS is your complete string with delimiter

                --你应该通过n-1来获得第n个位置

                --You should pass n-1 to obtain nth position

                替代 2:

                WITH T AS (SELECT 'Mike|Male||20000|Yes' X FROM DUAL)
                SELECT
                      X,
                      REGEXP_REPLACE ( X,
                                    '^([^|]*).*$',
                                    '1' )
                          Y1,
                      REGEXP_REPLACE ( X,
                                    '^[^|]*|([^|]*).*$',
                                    '1' )
                          Y2,
                      REGEXP_REPLACE ( X,
                                    '^([^|]*|){2}([^|]*).*$',
                                    '2' )
                          Y3,
                      REGEXP_REPLACE ( X,
                                    '^([^|]*|){3}([^|]*).*$',
                                    '2' )
                          Y4,
                      REGEXP_REPLACE ( X,
                                    '^([^|]*|){4}([^|]*).*$',
                                    '2' )
                          Y5
                FROM
                      T;
                

                替代 3:

                SELECT
                      REGEXP_SUBSTR ( REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                                '|',
                                                ';' ),
                                   '(^|;)([^;]*)',
                                   1,
                                   1,
                                   NULL,
                                   2 )
                          AS FIRST,
                      REGEXP_SUBSTR ( REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                                '|',
                                                ';' ),
                                   '(^|;)([^;]*)',
                                   1,
                                   2,
                                   NULL,
                                   2 )
                          AS SECOND,
                      REGEXP_SUBSTR ( REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                                '|',
                                                ';' ),
                                   '(^|;)([^;]*)',
                                   1,
                                   3,
                                   NULL,
                                   2 )
                          AS THIRD,
                      REGEXP_SUBSTR ( REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                                '|',
                                                ';' ),
                                   '(^|;)([^;]*)',
                                   1,
                                   4,
                                   NULL,
                                   2 )
                          AS FOURTH,
                      REGEXP_SUBSTR ( REGEXP_REPLACE ( 'Mike|Male||20000|Yes',
                                                '|',
                                                ';' ),
                                   '(^|;)([^;]*)',
                                   1,
                                   5,
                                   NULL,
                                   2 )
                          AS FIFTH
                FROM
                      DUAL;
                

                这篇关于regexp_substr 跳过空位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                Reset Sequence in oracle 11g(oracle 11g 中的重置序列)

                • <tfoot id='agPiN'></tfoot>

                    1. <legend id='agPiN'><style id='agPiN'><dir id='agPiN'><q id='agPiN'></q></dir></style></legend>

                        <bdo id='agPiN'></bdo><ul id='agPiN'></ul>

                          <tbody id='agPiN'></tbody>

                        <small id='agPiN'></small><noframes id='agPiN'>

                      • <i id='agPiN'><tr id='agPiN'><dt id='agPiN'><q id='agPiN'><span id='agPiN'><b id='agPiN'><form id='agPiN'><ins id='agPiN'></ins><ul id='agPiN'></ul><sub id='agPiN'></sub></form><legend id='agPiN'></legend><bdo id='agPiN'><pre id='agPiN'><center id='agPiN'></center></pre></bdo></b><th id='agPiN'></th></span></q></dt></tr></i><div id='agPiN'><tfoot id='agPiN'></tfoot><dl id='agPiN'><fieldset id='agPiN'></fieldset></dl></div>