简体   繁体   English

在 hive 中最后一次出现逗号后提取文本

[英]Extract text after last occurrence of comma in hive

I want to extract everything after last comma我想提取最后一个逗号后的所有内容

abc,xyz,tuv
abc,123,abc,def

I want the result as我想要的结果是

tuv
def

Using regexp_extract:使用 regexp_extract:

regexp_extract(col,',([^,]+)$',1)

Using split:使用拆分:

split(col,',')[size(split(col,','))-1]

Pls use请使用

substr(col,-1*instr(col,',',-1)+1)

So here instr will find position of comma from end of string.所以这里 instr 会从字符串末尾找到 position 个逗号。 Then substring will pick that many string from end.然后 substring 将从末尾选择那么多字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM