Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 之后。谢谢 SQL> with test (id, col) as 2 ( 3 select 1, '|||14444|10107|227931|10115||10118||11361|11485||10110||11512|16_Regex_Oracle - Fatal编程技术网

Regex 之后。谢谢 SQL> with test (id, col) as 2 ( 3 select 1, '|||14444|10107|227931|10115||10118||11361|11485||10110||11512|16

Regex 之后。谢谢 SQL> with test (id, col) as 2 ( 3 select 1, '|||14444|10107|227931|10115||10118||11361|11485||10110||11512|16,regex,oracle,Regex,Oracle,之后。谢谢 SQL> with test (id, col) as 2 ( 3 select 1, '|||14444|10107|227931|10115||10118||11361|11485||10110||11512|16666|||' from dual union all 4 select 2, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20' from

之后。谢谢
SQL> with test (id, col) as
  2    (
  3    select 1, '|||14444|10107|227931|10115||10118||11361|11485||10110||11512|16666|||' from dual union all
  4    select 2, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20'                     from dual
  5    ),
  6  temp as
  7    (select replace(regexp_substr(col, '(.*?)(\||$)', 1, column_value), '|', '') val,
  8            column_value lvl,
  9            id
 10     from test cross join table(cast(multiset(select level from dual
 11                                              connect by level <= regexp_count(col, '\|') + 1
 12                                             ) as sys.odcinumberlist))
 13    )
 14  select id,
 15    listagg(case when lvl in (4, 6, 8, 9, 11, 12, 13) then '|'
 16                 else val || case when lvl = 20 then '' else '|' end
 17            end, '')
 18            within group (order by case when lvl = 16 then 4
 19                                        when lvl =  4 then 16
 20                                        else lvl
 21                                   end) result
 22  from temp
 23  group by id;

        ID RESULT
---------- ------------------------------------------------------------
         1 |||11512|10107||10115|||||||10110|||16666|||
         2 1|2|3|16|5||7|||10||||14|15||17|18|19|20

SQL>
select regexp_replace(col1, 
     '^(\d*\|\d*\|\d*\|\d*\|)\d*\|(\d*\|)\d*\|(\d*\|)\d*\|\d*\|(\d*\|)\d*\|\d*\|\d*\|(\d*\|\d*\|)(\d*\|)(.*)$', 
     '\1\6\2|\3||\4|||\5|\7') as cc 
from table
CC
|||14444|16666|227931|||||11361|||||11512|||||
0|1|2|3|16|5||7|||10||||14|15||17|18|19|