Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count the number of occurences of a character in a string - BigQuery

We would like to run a query that returns no of character in the given string if i have a string say : Baitul Sharaf, 105 Hill Road, Bandra (west), Mumbai I want to count no of ',' in the above string (In above case 3)

see the reference for my question Count the number of occurrences of a character in a string in Javascript I want to achieve the same in BigQuery

like image 523
Ravindra Avatar asked May 12 '14 12:05

Ravindra


1 Answers

SELECT LENGTH(col) - LENGTH(REGEXP_REPLACE(col, ',', '')) FROM TableName

like image 113
Ravindra Avatar answered Sep 28 '22 00:09

Ravindra