<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 跳过空位置

      时间:2023-11-02

        <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 跳过空位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 PL/SQL 中反转字符串的过程 下一篇:在 pl/sql 中的同一过程中创建表和插入

                相关文章

              • <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>

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

                  2. <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>