Teradata中的REGEXP_SUBSTR

时间:2018-04-02 21:30:40

标签: regex teradata regexp-substr

我在XXX / XXXX / XXXX / XYYUX / YYY这样的栏目中有数据。我试图仅在第三个反斜杠(/)之后的前两个数字中提取' XY'在这个例子中。你能帮忙吗? 谢谢!

2 个答案:

答案 0 :(得分:0)

试试这个:

    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

答案 1 :(得分:-2)

尝试使用 - STRTOK('/88/209/89/132]', ' /]', 3)

返回第三个八位字节,'89'