Oracle的正则表达式与translate配合使用的示例

该示例演示了从描述字段中提取想要的关键信息,下面对同一字段进行标的编号与期数信息的提取。

select distinct  b.machdt || substr(lpad(trantm, 9, '0'), 1, 6) trantm,
                 custac,
                 trim(translate(regexp_substr(remark, '((-))[A-Z0-9]+'),
                                '-]',
                                ' ')) subjcd,
                 trim(translate(regexp_substr(remark, '(第)[A-Z0-9]+(期)'),
                                '第期',
                                ' ')) qishu
            from cbmain_user.my_table b
           where machdt > '20190201' 
 
translate的使用介绍:
   oracle translate() 详解+实例 

regexp_substr的使用介绍:
   Oracle中REGEXP_SUBSTR及其它支持正则表达式
 

猜你喜欢

转载自www.cnblogs.com/kevinlucky/p/11621326.html