Teradata 中的 REGEXP_SUBSTR [英] REGEXP_SUBSTR in Teradata

查看:32
本文介绍了Teradata 中的 REGEXP_SUBSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XXX/XXXX/XXXX/XYYUX/YYY 之类的列中有数据.我试图仅提取列中第三个反斜杠(/)之后的前两位数字,在此示例中为XY".你能帮忙吗?谢谢!

I am having data in a column like XXX/XXXX/XXXX/XYYUX/YYY. I am trying to extract only the first two digits after the 3rd backslash(/) in the column which is 'XY' in this example. Can you please help? Thanks!

推荐答案

试试这个:

    REGEXP_SUBSTR('XXX/XXXX/XXXX/XYYUX/YYY','^([^/]*/){3}\K..',1,1,'i')


'^' start of string
'([^/]*/){3}' looks for 0 or more non-slashes followed by a slash, 3 times
'\K' match reset operator drops the part of the string that has been matched up to this point
'..' grabs the next two characters in the string

这篇关于Teradata 中的 REGEXP_SUBSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆