You can translate the question and the replies:

Count the number of commas is a string

Is there a way to count the occurences of a comma in a string? I need to filter out any rows there there are NOT exactly 3 commas in that field.
user
30-03-2021 12:36:52 -0400

2 Answers

Hi, If I would like to filter the output of a view based on the occurrences of commas in a field, I would use the [LEN](https://community.denodo.com/docs/html/browse/latest/en//vdp/vql/appendix/syntax_of_condition_functions/text_processing_functions#len) and [REPLACE](https://community.denodo.com/docs/html/browse/latest/en//vdp/vql/appendix/syntax_of_condition_functions/text_processing_functions#replace) function in my query as given below, ***select from <viewname> where len(<fieldname>) - len(replace(<fieldname>, ',',' ')) != 3;*** Hope this helps!
Denodo Team
31-03-2021 08:21:51 -0400
Ok so this is the only workaround? There is no direct function to count the number of commas in a string or check via a regex expression? This solution worked but it seems clunky/inefficient.
user
31-03-2021 09:45:04 -0400
You must sign in to add an answer. If you do not have an account, you can register here