“contains” returns yes/no based on whether the keyword is found in a text.
But how can I get the number of occurrences the keyword is found in the text?
“contains” returns yes/no based on whether the keyword is found in a text.
But how can I get the number of occurrences the keyword is found in the text?
Hi there, @jayy… I’m kind of surprised that it doesn’t look like anything similar to this question has been asked before (I could easily be missing something with the searches I tried, though), so here is one way that appears to do what you have described.
What I am doing there is splitting the input element’s value by a space character and then filtering the results to the desired keyword and doing a count.
Maybe someone will post a better way to do it, but again, this suggestion does appear to achieve the desired result of counting the occurrences of a particular word in a text.
Hope this helps.
Best…
Mike
Thanks Mike!
I’ll try this out - it looks doable Probably need to “-1” to it, and cater for the special case where the keyword is at the start or at the end of the text.
Just hope that it wouldn’t take up too much execution time, as I need to compute this several times on the same page.
Bubble needs a better library of very basic string handling functions that are present in every modern programming language.
This topic was automatically closed after 70 days. New replies are no longer allowed.