第一种情况 文屏路39-1号802室
==
拿这个来说 最后展示为
路        号    座                       室
文屏路  39-1    (没有标明就为空)       802  这个比较好解决。可以搞定下面的难题:1:水仙大街42号闽南商业城综合楼B幢302室这个最终的展现是路         号    座      室
水仙大街  2号    B     3022: 厦港新村23-302-0002 这个最终的展现是路         号    座      室
厦港新村   23    空      302 像这个形式 座都是为空的  求解答!!!

解决方案 »

  1.   


    with t(col) as(
    select '文屏路39-1号802室' from dual
    union all select '水仙大街42号闽南商业城综合楼B幢302室' from dual
    union all select '厦港新村23-302-0002' from dual
    )
    select 
    regexp_substr(col,'[^0-9]*') 路,
    regexp_replace(
    decode(regexp_substr(col,'[0-9-]+号'),null,regexp_substr(col,'[0-9]+'),
    regexp_substr(col,'[0-9-]+号')),'号','') 号,
    regexp_replace(regexp_substr(col,'[0-9a-zA-Z]+(座|幢)'),'(座|幢)','') 座,
        regexp_replace(
    decode(regexp_substr(col,'[0-9]+室'),null,regexp_substr(col,'[-]{1}[0-9]+'),
    regexp_substr(col,'[0-9]+室')),'室|-','') 室
    from t;
    /*
    路         号         座         室                                             
    ---------- ---------- ---------- ----------                                     
    文屏路     39-1                  802                                            
    水仙大街   42         B          302                                            
    厦港新村   23                    302  
    */