Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count occurrences of a character in a string in Presto?

Tags:

presto

trino

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

like image 861
Zaynul Abadin Tuhin Avatar asked Oct 20 '25 16:10

Zaynul Abadin Tuhin


1 Answers

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', '\.'))
like image 157
Ori N Avatar answered Oct 27 '25 04:10

Ori N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!