1. <small id='zrdTu'></small><noframes id='zrdTu'>

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

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

    1. Oracle 11g 通过正则表达式获取所有匹配的事件

      时间:2023-09-20
      <legend id='WcHXl'><style id='WcHXl'><dir id='WcHXl'><q id='WcHXl'></q></dir></style></legend>

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

          • <bdo id='WcHXl'></bdo><ul id='WcHXl'></ul>

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

                <tfoot id='WcHXl'></tfoot>
              1. 本文介绍了Oracle 11g 通过正则表达式获取所有匹配的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 Oracle 11g,我想使用 REGEXP_SUBSTR 来匹配给定模式的所有出现.例如

                I'm using Oracle 11g and I would like to use the REGEXP_SUBSTR to match all the occurrences for a given pattern. For example

                 SELECT
                  REGEXP_SUBSTR('Txa233141b Ta233141 Ta233142 Ta233147 Ta233148',
                  '(^|s)[A-Za-z]{2}[0-9]{5,}(s|$)') "REGEXP_SUBSTR"
                  FROM DUAL;
                

                仅返回第一个匹配项 Ta233141,但我想返回与正则表达式匹配的其他匹配项,即 Ta233142 Ta233147 Ta233148.

                returns only the first match Ta233141 but I would like to return the other occurrences that match the regex, meaning Ta233142 Ta233147 Ta233148.

                推荐答案

                REGEXP_SUBSTR 只返回一个值.您可以将字符串转换为伪表,然后查询匹配项.目前有一种基于 XML 的方法可以做到这一点,但只要您只有一个源字符串,就可以使用 connect-by:

                REGEXP_SUBSTR only returns one value. You could turn your string into a pseudo-table and then query that for matches. There's an XML-based way of doing this that escapes me at the moment, but using connect-by works, as long as you only have one source string:

                SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, LEVEL) AS substr
                FROM (
                    SELECT 'Txa233141b Ta233141 Ta233142 Ta233147 Ta233148' AS str FROM DUAL
                )
                CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(str, '[^ ]+')) + 1;
                

                ...给你:

                SUBSTR             
                --------------------
                Txa233141b           
                Ta233141             
                Ta233142             
                Ta233147            
                Ta233148            
                

                ...并且您可以使用原始模式的稍微简单的版本对其进行过滤:

                ... and you can filter that with a slightly simpler version of your original pattern:

                SELECT substr
                FROM (
                    SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, LEVEL) AS substr
                    FROM (
                        SELECT 'Txa233141b Ta233141 Ta233142 Ta233147 Ta233148' AS str
                        FROM DUAL
                    )
                    CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(str, '[^ ]+')) + 1
                )
                WHERE REGEXP_LIKE(substr, '^[A-Za-z]{2}[0-9]{5,}$');
                
                SUBSTR             
                --------------------
                Ta233141             
                Ta233142             
                Ta233147             
                Ta233148             
                

                这不是很漂亮,但也不是在一个字段中保存多个值.

                Which isn't very pretty, but neither is holding multiple values in one field.

                这篇关于Oracle 11g 通过正则表达式获取所有匹配的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 Oracle 中查询 CLOB 列 下一篇:PLS-00428:此 SELECT 语句中需要 INTO 子句

                相关文章

                    <legend id='UhQYS'><style id='UhQYS'><dir id='UhQYS'><q id='UhQYS'></q></dir></style></legend><tfoot id='UhQYS'></tfoot>

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

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