Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive - Count number of occurrences of character

Tags:

regex

hive

I am trying to count number of occurrences of pipe symbol in Hive - (6)

select length(regexp_replace('220138|251965797?AIRFR?150350161961|||||','^(?:[^|]*\\|)(\\|)','')) from smartmatching limit 10

This is what I am trying and I am not getting it right.

like image 870
Adithya Kumar Avatar asked Dec 25 '22 06:12

Adithya Kumar


1 Answers

This will work

SELECT LENGTH(regexp_replace('220138|251965797?AIRFR?150350161961|||||','[^|]',''))
like image 106
rock321987 Avatar answered Jan 05 '23 03:01

rock321987