'How to count occurrences of a character in a string in Presto?
I am trying to find the number of frequency of a character in a string in Presto.
like 129.11.20.0
and I wan to find number of dot .
in this string.
just wondering if any function available
Solution 1:[1]
I was looking for the same in AWS athena, which is a managed presto service. It doesn't support regexp_count, so I used the following expression instead:
SELECT CARDINALITY(REGEXP_EXTRACT_ALL('1.1.1.1', '\.'))
Solution 2:[2]
You can use regexp_count function.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ori N |
Solution 2 |